Finding System Folders

by Nov 26, 2008

When you automate file system tasks, you may want to know where special folders such as MyPictures or Documents are located. The .NET class Environment provides a static method named GetFolderPath() which provides this information. To find the location of your desktop, use this:

[Environment]::GetFolderPath('Desktop')

If you need to find out the short names of other important system folders, you can simply specify anything else, any you will receive a red error message that lists all of the legal short names:

[Environment]::GetFolderPath('give me more!')