Using Special Folders in .NET

How many times have you wanted to access in one way or another a system folder on your computer using VB.NET or C#.  Well, thanks to the .NET Framework and the Environment.SpecialFolder enumeration (which by the way has been around for a while) it’s as easy as this…

System.Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)

The “GetFolderPath” method will return a string representing the path of the special folder enumeration provided. It does not include the “” at the end of the path so if you have strong desire to append subfolders or a filename you need to include that along with it.

You should know that at the time this posting was written there are almost 4 dozen special folders made available to .NET developers. They range from the application data folder to the user’s desktop to their music folder. This means it is easy to reference just about every system folder on a user’s machine and there should be no excuse as to why you attempted to hard code one of these paths!

Tagged with: , , , ,

Leave a Reply