(talking smart client – windows forms app here, not asp.net)
I was using System.IO.Directory.GetCurrentDirectory to find DLL’s that are to be loaded by reflection in a particular app. But when a user goes out and does something like look up something in windows explorer, that changes the definition of the system’s current directory and you are no longer pointed to the startup path. Then when the user tries to load up the next form – it can’t’ be found! Oops.
GetCurrentDirectory’s definition is “current working directory“. And even in the reference it explicitly says: “The current directory is distinct from the original directory, which is the one from which the process was started.“
So when you need to use the startup path, use the Application.StartupPath which is in the System.Windows.Forms namespace.
(oh, I’m just so embarrassed! 🙂 )
Sign up for my newsletter so you don't miss my conference & Pluralsight course announcements!