BCL mscorlib [00 00 00 00 00 00 00 00 04 00 00 00 00 00 00 00 ] 1.0.5000.0 2.0.0.0 4.0.0.0 All public static members of this type are safe for multithreaded operations. No instance members are guaranteed to be thread safe. System.Object System.Runtime.InteropServices.ComVisible(true)

The .NET Framework does not support direct access to physical disks through paths that are device names, such as "\\.\PHYSICALDRIVE0 ".

A path is a string that provides the location of a file or directory. A path does not necessarily point to a location on disk; for example, a path might map to a location in memory or on a device. The exact format of a path is determined by the current platform. For example, on some systems, a path can start with a drive or volume letter, while this element is not present in other systems. On some systems, file paths can contain extensions, which indicate the type of information stored in the file. The format of a file name extension is platform-dependent; for example, some systems limit extensions to three characters, and others do not. The current platform also determines the set of characters used to separate the elements of a path, and the set of characters that cannot be used when specifying paths. Because of these differences, the fields of the Path class as well as the exact behavior of some members of the Path class are platform-dependent.

A path can contain absolute or relative location information. Absolute paths fully specify a location: the file or directory can be uniquely identified regardless of the current location. Relative paths specify a partial location: the current location is used as the starting point when locating a file specified with a relative path. To determine the current directory, call .

Most members of the Path class do not interact with the file system and do not verify the existence of the file specified by a path string. Path class members that modify a path string, such as , have no effect on names of files in the file system. Path members do, however, validate the contents of a specified path string, and throw an exception if the string contains characters that are not valid in path strings, as defined in the characters returned from the method. For example, on Windows-based desktop platforms, invalid path characters might include quote ("), less than (<), greater than (>), pipe (|), backspace (\b), null (\0), and Unicode characters 16 through 18 and 20 through 25.

The members of the Path class enable you to quickly and easily perform common operations such as determining whether a file name extension is part of a path, and combining two strings into one path name.

All members of the Path class are static and can therefore be called without having an instance of a path.

In members that accept a path as an input string, that path must be well-formed or an exception is raised. For example, if a path is fully qualified but begins with a space, the path is not trimmed in methods of the class. Therefore, the path is malformed and an exception is raised. Similarly, a path or a combination of paths cannot be fully qualified twice. For example, "c:\temp c:\windows" also raises an exception in most cases. Ensure that your paths are well-formed when using methods that accept a path string.

In members that accept a path, the path can refer to a file or just a directory. The specified path can also refer to a relative path or a Universal Naming Convention (UNC) path for a server and share name. For example, all the following are acceptable paths:

"c:\\MyDir\\MyFile.txt" in C#, or "c:\MyDir\MyFile.txt" in Visual Basic.

"c:\\MyDir" in C#, or "c:\MyDir" in Visual Basic.

"MyDir\\MySubdir" in C#, or "MyDir\MySubDir" in Visual Basic.

"\\\\MyServer\\MyShare" in C#, or "\\MyServer\MyShare" in Visual Basic.

Because all these operations are performed on strings, it is impossible to verify that the results are valid in all scenarios. For example, the method parses a string that you pass to it and returns the extension from that string. However, this does not mean that a file with that extension exists on the disk.

For a list of common I/O tasks, see Common I/O Tasks.

Performs operations on instances that contain file or directory path information. These operations are performed in a cross-platform manner.

- Field
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Char

  The character stored in this field cannot be in . This field can be set to the same value as . AltDirectorySeparatorChar and DirectorySeparatorChar are both valid for separating directory levels in a path string.

  The value of this field is a backslash ('\') on UNIX, and a slash ('/') on Windows and Macintosh operating systems.

  Provides a platform-specific alternate character used to separate directory levels in a path string that reflects a hierarchical file system organization.

  0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.String `` `` contains one or more implementation-specific invalid characters.

  If neither nor contains a period (.), ChangeExtension adds the period.

  The parameter can contain multiple periods and any valid path characters, and can be any length. If is null, the returned string contains the contents of with the last period and all characters following it removed.

  If is an empty string, the returned path string contains the contents of with any characters following the last period removed.

  If does not have an extension and is not null, the returned string contains followed by .

  If is not null and does not contain a leading period, the period is added.

  If contains a multiple extension separated by multiple periods, the returned string contains the contents of with the last period and all characters following it replaced by . For example, if is "\Dir1\examples\pathtests.csx.txt" and is "cs", the modified path is "\Dir1\examples\pathtests.csx.cs".

  It is not possible to verify that the returned results are valid in all scenarios. For example, if is empty, is appended.

  For a list of common I/O tasks, see Common I/O Tasks.

  Changes the extension of a path string.

  The modified path information.

  On Windows-based desktop platforms, if is null or an empty string (""), the path information is returned unmodified. If is null, the returned string contains the specified path with its extension removed. If has no extension, and is not null, the returned path string contains appended to the end of .

  The path information to modify. The path cannot contain any of the characters defined in . The new extension (with or without a leading period). Specify null to remove an existing extension from . 0
- Method
  4.0.0.0
  System.String `System.ParamArray`

  should be an array of the parts of the path to combine. If the one of the subsequent paths is an absolute path, then the combine operation resets starting with that absolute path, discarding all previous combined paths.

  Zero-length strings are omitted from the combined path.

  The parameters are not parsed if they have white space.

  Not all invalid characters for directory and file names are interpreted as unacceptable by the Combine method, because you can use these characters for search wildcard characters. For example, while Path.Combine("c:\\", "*.txt") might be invalid if you were to create a file from it, it is valid as a search string. It is therefore successfully interpreted by the Combine method.

  Combines an array of strings into a path.

  The combined paths.

  An array of parts of the path.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.String `` `` or is .

  or contains one or more implementation-specific invalid characters.

  The following example demonstrates using the method on a Windows system.

  `using System; using System.IO; class CombineTest { public static void Main() { string path1, path2; Console.WriteLine("Dir char is {0} Alt dir char is {1}", Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar ); path1 = "foo.txt"; path2 = "\\ecmatest\\examples"; Console.WriteLine("{0} combined with {1} = {2}",path1, path2 , Path.Combine(path1, path2)); path1 = "\\ecmatest\\examples"; path2 = "foo.txt"; Console.WriteLine("{0} combined with {1} = {2}",path1, path2 , Path.Combine(path1, path2)); } }`

  The output is

  Dir char is \ Alt dir char is /

  foo.txt combined with \ecmatest\examples = \ecmatest\examples

  \ecmatest\examples combined with foo.txt = \ecmatest\examples\foo.txt

  If is not a drive reference (that is, "C:" or "D:") and does not end with a valid separator character as defined in , , or , is appended to before concatenation.

  If does not include a root (for example, if does not start with a separator character or a drive specification), the result is a concatenation of the two paths, with an intervening separator character. If includes a root, is returned.

  The parameters are not parsed if they have white space. Therefore, if includes white space (for example, " c:\\ "), the method appends to instead of returning only .

  Not all invalid characters for directory and file names are interpreted as unacceptable by the Combine method, because you can use these characters for search wildcard characters. For example, while Path.Combine("c:\\", "*.txt") might be invalid if you were to create a file from it, it is valid as a search string. It is therefore successfully interpreted by the Combine method.

  For a list of common I/O tasks, see Common I/O Tasks.

  Combines two strings into a path.

  The combined paths. If one of the specified paths is a zero-length string, this method returns the other path. If contains an absolute path, this method returns .

  The first path to combine. The second path to combine. 0
- Method
  4.0.0.0
  System.String `` `` ``

  should be an absolute path (for example, "d:\archives" or "\\archives\public"). If or is also an absolute path, the combine operation discards all previously combined paths and resets to that absolute path.

  Zero-length strings are omitted from the combined path.

  If is not a drive reference (that is, "C:" or "D:") and does not end with a valid separator character as defined in , , or , is appended to before concatenation.

  If does not include a root (for example, if does not start with a separator character or a drive specification), the result is a concatenation of the two paths, with an intervening separator character. If includes a root, is returned.

  The parameters are not parsed if they have white space. Therefore, if includes white space (for example, " c:\\ "), the method appends to instead of returning only .

  Not all invalid characters for directory and file names are interpreted as unacceptable by the Combine method, because you can use these characters for search wildcard characters. For example, while Path.Combine("c:\\", "*.txt") might be invalid if you were to create a file from it, it is valid as a search string. It is therefore successfully interpreted by the Combine method.

  Combines three strings into a path.

  The combined paths.

  The first path to combine. The second path to combine. The third path to combine.
- Method
  4.0.0.0
  System.String `` `` `` ``

  should be an absolute path (for example, "d:\archives" or "\\archives\public"). If one of the subsequent paths is also an absolute path, the combine operation discards all previously combined paths and resets to that absolute path.

  Zero-length strings are omitted from the combined path.

  If is not a drive reference (that is, "C:" or "D:") and does not end with a valid separator character as defined in , , or , is appended to before concatenation.

  If does not include a root (for example, if does not start with a separator character or a drive specification), the result is a concatenation of the two paths, with an intervening separator character. If includes a root, is returned.

  The parameters are not parsed if they have white space. Therefore, if includes white space (for example, " c:\\ "), the method appends to instead of returning only .

  Not all invalid characters for directory and file names are interpreted as unacceptable by the Combine method, because you can use these characters for search wildcard characters. For example, while Path.Combine("c:\\", "*.txt") might be invalid if you were to create a file from it, it is valid as a search string. It is therefore successfully interpreted by the Combine method.

  Combines four strings into a path.

  The combined paths.

  The first path to combine. The second path to combine. The third path to combine. The fourth path to combine.
- Field
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Char

  The character stored in this field cannot be in . and DirectorySeparatorChar are both valid for separating directory levels in a path string.

  The value of this field is a slash ("/") on UNIX, and a backslash ("\") on the Windows and Macintosh operating systems.

  Provides a platform-specific character used to separate directory levels in a path string that reflects a hierarchical file system organization.

  0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.String ``

  contains one or more implementation-specific invalid characters.

  The following example demonstrates using the method on a Windows system.

  `using System; using System.IO; class GetDirectoryTest { public static void Main() { string [] paths = { @"\ecmatest\examples\pathtests.txt", @"\ecmatest\examples\", "pathtests.xyzzy", @"\", @"C:\", @"\\myserver\myshare\foo\bar\baz.txt" }; foreach (string pathString in paths) { string s = Path.GetDirectoryName(pathString); Console.WriteLine("Path: {0} directory is {1}",pathString, s== null? "null": s); } } }`

  The output is

  Path: \ecmatest\examples\pathtests.txt directory is \ecmatest\examples

  Path: \ecmatest\examples\ directory is \ecmatest\examples

  Path: pathtests.xyzzy directory is

  Path: \ directory is null

  Path: C:\ directory is null

  Path: \\myserver\myshare\foo\bar\baz.txt directory is \\myserver\myshare\foo\bar

  In most cases, the string returned by this method consists of all characters in the path up to but not including the last or . If the path consists of a root directory, such as "c:\", null is returned. Note that this method does not support paths using "file:". Because the returned path does not include the or , passing the returned path back into the method will result in the truncation of one folder level per subsequent call on the result string. For example, passing the path "C:\Directory\SubDirectory\test.txt" into the method will return "C:\Directory\SubDirectory". Passing that string, "C:\Directory\SubDirectory", into will result in "C:\Directory".

  For a list of common I/O tasks, see Common I/O Tasks.

  Returns the directory information for the specified path string.

  Directory information for , or null if denotes a root directory or is null. Returns if does not contain directory information.

  The path of a file or directory. 0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.String ``

  contains one or more implementation-specific invalid characters.

  The following example demonstrates using the method on a Windows system.

  `using System; using System.IO; class GetDirectoryTest { public static void Main(){ string [] paths = { @"\ecmatest\examples\pathtests.txt", @"\ecmatest\examples\", "pathtests.xyzzy", "pathtests.xyzzy.txt", @"\", "" }; foreach (string pathString in paths){ string s = Path.GetExtension (pathString); if (s == String.Empty) s= "(empty string)"; if (s == null) s= "null"; Console.WriteLine("{0} is the extension of {1}", s, pathString); } } }`

  The output is

  .txt is the extension of \ecmatest\examples\pathtests.txt

  (empty string) is the extension of \ecmatest\examples\

  .xyzzy is the extension of pathtests.xyzzy

  .txt is the extension of pathtests.xyzzy.txt

  (empty string) is the extension of \

  (empty string) is the extension of

  The extension of is obtained by searching for a period (.), starting with the last character in path and continuing toward the start of path. If a period is found before a or character, the returned string contains the period and the characters after it; otherwise, is returned.

  For a list of common I/O tasks, see Common I/O Tasks.

  Returns the extension of the specified path string.

  The extension of the specified path (including the period "."), or null, or . If is null, returns null. If does not have extension information, returns .

  The path string from which to get the extension. 0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.String `` contains one or more implementation-specific invalid characters.

  The following example demonstrates the behavior of the method on a Windows system.

  `using System; using System.IO; class FileNameTest { public static void Main() { string [] paths = {"pathtests.txt", @"\ecmatest\examples\pathtests.txt", "c:pathtests.txt", @"\ecmatest\examples\", "" }; foreach (string p in paths) { Console.WriteLine("Path: {0} filename = {1}",p, Path.GetFileName(p)); } } }`

  The output is

  Path: pathtests.txt filename = pathtests.txt

  Path: \ecmatest\examples\pathtests.txt filename = pathtests.txt

  Path: c:pathtests.txt filename = pathtests.txt

  Path: \ecmatest\examples\ filename =

  Path: filename =

  The returned value is null if the file path is null.

  The separator characters used to determine the start of the file name are and .

  For a list of common I/O tasks, see Common I/O Tasks.

  Returns the file name and extension of the specified path string.

  The characters after the last directory character in . If the last character of is a directory or volume separator character, this method returns . If is null, this method returns null.

  The path string from which to obtain the file name and extension. 0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.String `` contains one or more implementation-specific invalid characters.

  This method does not verify that the path or file name exists.

  For a list of common I/O tasks, see Common I/O Tasks.

  Returns the file name of the specified path string without the extension.

  The string returned by , minus the last period (.) and all characters following it.

  The path of the file. 0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.String ``

  is a zero-length string, contains only white space, or contains one or more implementation-specific invalid characters.

  -or-

  The system could not retrieve the absolute path.

  The caller does not have the required permissions. is . The length of or the absolute path information for exceeds the system-defined maximum length. Requires permission to access path information. See .

  The following example demonstrates the method on a Windows system. In this example, the absolute path for the current directory is c:\ecmatest\examples.

  `using System; using System.IO; class GetDirectoryTest { public static void Main() { string [] paths = { @"\ecmatest\examples\pathtests.txt", @"\ecmatest\examples\", "pathtests.xyzzy", @"\", }; foreach (string pathString in paths) Console.WriteLine("Path: {0} full path is {1}",pathString, Path.GetFullPath(pathString)); } }`

  The output is

  Path: \ecmatest\examples\pathtests.txt full path is C:\ecmatest\examples\pathtests.txt

  Path: \ecmatest\examples\ full path is C:\ecmatest\examples\

  Path: pathtests.xyzzy full path is C:\ecmatest\examples\pathtests.xyzzy

  Path: \ full path is C:\

  The .NET Framework does not support direct access to physical disks through paths that are device names, such as "\\.\PHYSICALDRIVE0 ".

  The absolute path includes all information required to locate a file or directory on a system.

  The file or directory specified by is not required to exist. For example, if c:\temp\newdir is the current directory, calling GetFullPath on a file name such as test.txt returns c:\temp\newdir\test.txt. The file need not exist.

  However, if does exist, the caller must have permission to obtain path information for . Note that unlike most members of the class, this method accesses the file system.

  This method uses current directory and current volume information to fully qualify . If you specify a file name only in , GetFullPath returns the fully qualified path of the current directory.

  If you pass in a short file name, it is expanded to a long file name.

  If a path contains no significant characters it is invalid unless it contains one or more "." characters followed by any number of spaces, then it will be parsed as either "." or "..".

  For a list of common I/O tasks, see Common I/O Tasks.

  Returns the absolute path for the specified path string.

  The fully qualified location of , such as "C:\MyFile.txt".

  The file or directory for which to obtain absolute path information. 0
- Method
  2.0.0.0
  4.0.0.0
  System.Char[]

  The array returned from this method is not guaranteed to contain the complete set of characters that are invalid in file and directory names. The full set of invalid characters can vary by file system. For example, on Windows-based desktop platforms, invalid path characters might include ASCII/Unicode characters 1 through 31, as well as quote ("), less than (<), greater than (>), pipe (|), backspace (\b), null (\0) and tab (\t).

  Gets an array containing the characters that are not allowed in file names.

  An array containing the characters that are not allowed in file names.

- Method
  2.0.0.0
  4.0.0.0
  System.Char[]

  The array returned from this method is not guaranteed to contain the complete set of characters that are invalid in file and directory names. The full set of invalid characters can vary by file system. For example, on Windows-based desktop platforms, invalid path characters might include ASCII/Unicode characters 1 through 31, as well as quote ("), less than (<), greater than (>), pipe (|), backspace (\b), null (\0) and tab (\t).

  Gets an array containing the characters that are not allowed in path names.

  An array containing the characters that are not allowed in path names.

- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.String `` contains one or more implementation-specific invalid characters or is equal to .

  The following example demonstrates the method.

  `using System; using System.IO; class GetPathRootTest { public static void Main() { string [] paths = { @"\ecmatest\examples\pathtests.txt", "pathtests.xyzzy", @"\", @"C:\", @"\\myserver\myshare\foo\bar\baz.txt" }; foreach (string pathString in paths) { string s = Path.GetPathRoot(pathString); Console.WriteLine("Path: {0} Path root is {1}",pathString, s== null? "null": s); } } }`

  The output is

  Path: \ecmatest\examples\pathtests.txt Path root is \

  Path: pathtests.xyzzy Path root is

  Path: \ Path root is \

  Path: C:\ Path root is C:\

  Path: \\myserver\myshare\foo\bar\baz.txt Path root is \\myserver\myshare

  This method does not verify that the path or file name exists.

  Possible patterns for the string returned by this method are as follows:

  An empty string ( specified a relative path on the current drive or volume).

  "/" ( specified an absolute path on the current drive).

  "X:" ( specified a relative path on a drive, where X represents a drive or volume letter).

  "X:/" ( specified an absolute path on a given drive).

  "\\ComputerName\SharedFolder" (a UNC path).

  The .NET Framework does not support direct access to physical disks through paths that are device names, such as "\\.\PHYSICALDRIVE0 ".

  For a list of common I/O tasks, see Common I/O Tasks.

  Gets the root directory information of the specified path.

  The root directory of , such as "C:\", or null if is null, or an empty string if does not contain root directory information.

  The path from which to obtain root directory information. 0
- Method
  2.0.0.0
  4.0.0.0
  System.String

  The method returns a cryptographically strong, random string that can be used as either a folder name or a file name. Unlike , does not create a file. When the security of your file system is paramount, this method should be used instead of .

  Returns a random folder name or file name.

  A random folder name or file name.

- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.String

  This method creates a temporary file with a .TMP file extension. The temporary file is created within the user’s temporary folder, which is the path returned by the method.

  The method will raise an if it is used to create more than 65535 files without deleting previous temporary files.

  The method will raise an if no unique temporary file name is available. To resolve this error, delete all unneeded temporary files.

  For a list of common I/O tasks, see Common I/O Tasks.

  Creates a uniquely named, zero-byte temporary file on disk and returns the full path of that file.

  The full path of the temporary file.

  0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.String The caller does not have the required permission. Requires unrestricted access to environment variables. See .

  This method checks for the existence of environment variables in the following order and uses the first path found:

  The path specified by the TMP environment variable.

  The path specified by the TEMP environment variable.

  The path specified by the USERPROFILE environment variable.

  The Windows directory.

  Returns the path of the current user's temporary folder.

  The path to the temporary folder, ending with a backslash.

  0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Boolean `` contains one or more implementation-specific invalid characters.

  Starting from the end of , this method searches for a period (.) followed by at least one character. If this pattern is found before a , , or character is encountered, this method returns true.

  For a list of common I/O tasks, see Common I/O Tasks.

  Determines whether a path includes a file name extension.

  true if the characters that follow the last directory separator (\\ or /) or volume separator (:) in the path include a period (.) followed by one or more characters; otherwise, false.

  The path to search for an extension. 0
- Field
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Obsolete("see GetInvalidPathChars and GetInvalidFileNameChars methods.")
  System.Char[]

  The array returned from this method is not guaranteed to contain the complete set of characters that are invalid in file and directory names. The full set of invalid characters can vary by file system. For example, on Windows-based desktop platforms, invalid path characters might include ASCII/Unicode characters 1 through 31, as well as quote ("), less than (<), greater than (>), pipe (|), backspace (\b), null (\0) and tab (\t).

  Do not use if you think your code might execute in the same application domain as untrusted code. is an array, so its elements can be overwritten. If untrusted code overwrites elements of , it might cause your code to malfunction in ways that could be exploited.

  Provides a platform-specific array of characters that cannot be specified in path string arguments passed to members of the class.

- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Boolean `` contains one or more implementation-specific invalid characters.

  The method returns true if the first character is a directory separator character such as "\", or if the path starts with a drive letter and colon (:). For example, it returns true for strings such as "\\MyDir\\MyFile.txt", "C:\\MyDir", or "C:MyDir". It returns false for strings such as "MyDir".

  This method does not verify that the path or file name exists.

  For a list of common I/O tasks, see Common I/O Tasks.

  Gets a value indicating whether the specified path string contains a root.

  true if contains a root; otherwise, false.

  The path to test. 0
- Field
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Char

  On Windows-based desktop platforms, the value of this field is the semicolon (;) by default, but might vary on other platforms.

  A platform-specific separator character used to separate path strings in environment variables.

  0
- Field
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Char

  The value of this field is a colon (:) on Windows and Macintosh, and a slash (/) on UNIX operating systems. This is most useful for parsing paths such as "c:\windows" or "MacVolume:System Folder".

  Provides a platform-specific volume separator character.

0