spig
spig

Reputation: 1705

How do I access special directories in Windows?

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

Upvotes: 7

Views: 6564

Answers (4)

Reed Copsey
Reed Copsey

Reputation: 564323

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

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

Upvotes: 14

Aliostad
Aliostad

Reputation: 81660

Use:

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

Where * is one of the enum values.

Upvotes: 7

Jonathan
Jonathan

Reputation: 1507

System.Environment.SpecialFolder.MyComputer

etc.

Upvotes: 3

Giorgi
Giorgi

Reputation: 30873

Use Environment.GetFolderPath Method

Upvotes: 2

Related Questions