Directories

There are some special directories easily available through use of the Environment.SpecialFolder enumeration: ApplicationData, Favorites, Personal, Programs, StartMenu and Startup. But it is a bit harder to e.g. get the current directory of the running application.
System.IO.Directory.GetCurrentDirectory() doesn’t work; it will give you an NotImplementedException at runtime.

To get it as string type:

System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetModules()[0].FullyQualifiedName);
Note the GetModules()[0] if you have more than one module.
To get the special folders:

Environment.GetFolderPath(Environment.SpecialFolder.Programs);

(I give up trying to format the text, this wordpress text editor is by far the worst  I’ve ever tried!)

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: