Search code examples
c#.netwindowsspecial-folders

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?


Solution

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

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