C# Environment GetFolderPath (Environment.SpecialFolder)

Description

Environment GetFolderPath(Environment.SpecialFolder) gets the path to the system special folder that is identified by the specified enumeration.

Syntax

Environment.GetFolderPath(Environment.SpecialFolder) has the following syntax.


public static string GetFolderPath(
  Environment.SpecialFolder folder
)

Parameters

Environment.GetFolderPath(Environment.SpecialFolder) has the following parameters.

  • folder - An enumerated constant that identifies a system special folder.

Returns

Environment.GetFolderPath(Environment.SpecialFolder) method returns The path to the specified system special folder, if that folder physically exists on your computer; otherwise, an empty string (""). A folder will not physically exist if the operating system did not create it, the existing folder was deleted, or the folder is a virtual directory, such as My Computer, which does not correspond to a physical path.

Example

The following example demonstrates how to use the GetFolderPath method to return and display the path associated with the folder parameter.


/*from w w w .  j  av  a2 s  .  c om*/
using System;

class Sample 
{
    public static void Main() 
    {
       Console.WriteLine("GetFolderPath: {0}", 
                 Environment.GetFolderPath(Environment.SpecialFolder.System));
    }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    System »




Array
BitConverter
Boolean
Byte
Char
Console
ConsoleKeyInfo
Convert
DateTime
DateTimeOffset
Decimal
Double
Enum
Environment
Exception
Guid
Int16
Int32
Int64
Math
OperatingSystem
Random
SByte
Single
String
StringComparer
TimeSpan
TimeZone
TimeZoneInfo
Tuple
Tuple
Tuple
Type
UInt16
UInt32
UInt64
Uri
Version