tags:

views:

74

answers:

4

What is the C# syntax to retrieve the user's desktop, documents folder and other system folders on windows?

+2  A: 

Use Environment.GetFolderPath Method

Giorgi
+3  A: 
System.Environment.SpecialFolder.MyComputer

etc.

Jonathan
That's just an enum.
Giorgi
This doesn't actually give you the path - it's an enumeration. You need to use this with Environment.GetFolderPath to get anything useful...
Reed Copsey
You're right, but a glance at http://msdn.microsoft.com/en-us/library/system.environment.specialfolder.aspx fills in the rest of the details.
Jonathan
+6  A: 

Use:

string folder = Environment.GetFolderPath(Environment.SpecialFolder.*);

Where * is one of the enum values.

Aliostad
+4  A: 

You can use Environment.GetFolderPath with the Environment.SpecialFolder enumeration. For example:

string desktopPath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
Reed Copsey