C# Environment GetFolderPath (Environment.SpecialFolder, Environment .SpecialFolderOption)

Description

Environment GetFolderPath(Environment.SpecialFolder, Environment.SpecialFolderOption) gets the path to the system special folder that is identified by the specified enumeration, and uses a specified option for accessing special folders.

Syntax

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


public static string GetFolderPath(
  Environment.SpecialFolder folder,
  Environment.SpecialFolderOption option
)

Parameters

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

  • folder - An enumerated constant that identifies a system special folder.
  • option - Specifies options to use for accessing a special folder.

Returns

Environment.GetFolderPath(Environment.SpecialFolder, Environment.SpecialFolderOption) 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

Gets the path to the system special folder that is identified by the specified enumeration, and uses a specified option for accessing special folders.


/*from  ww  w . ja v a 2 s  . c  o  m*/
using System;

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

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