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 All public static members of this type are safe for multithreaded operations. No instance members are guaranteed to be thread safe. System.Object

Performs operations on instances that contain file or directory path information.

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. Paths are composed of the components described below. Component names are shown in

and the following table describes the symbols used in component definitions:

Symbol
Description
< >
Indicates a path component.
{ }
Indicates a grouping; either all components in a grouping are present, or none are permitted to be present.
*
Indicates that the component or grouping that immediately precedes this symbol can appear zero, one, or multiple times.
?
Indicates that the component or grouping that immediately precedes this symbol can appear zero, or one times.
+
Indicates string concatenation.

The components that define a path are as follows:

: A string that specifies one or more directory levels in a file system. If a directory name contains multiple levels, a separates the levels; however, a directory name does not begin or end with a directory separator character. In the example path C:/foo/bar/bat.txt, the directory name is "foo/bar". returns the directory name component of a path. Note that this method does include a beginning separator character if one is included in the specified path.

: An implementation-specific constant string containing a single printable non-alphanumeric character used to separate levels in a file system. In the example path C:/foo/bar/bat.txt, the directory separator character is "/". The and store implementation-specific directory separator characters .

: A string that consists of the characters at the end of a file name, from and including the last . The minimum and maximum lengths of extension components are implementation-specific. In the example path C:/foo/bar/bat.txt , the is ".txt". The method returns the extension component of a path.

: An implementation-specific constant string composed of a single character that appears after the last character in the component indicating the beginning of the component. If the extension separator characteris the first character in a , it is not interpreted as a extension separator character If more than one extension separator characterappears in a file name, only the last occurrence is the extension separator character; all other occurrences are part of the file base component In the example path C:/foo/bar/bat.txt, the extension separator character is ".".

: A string containing the with the component removed. In the example path C:/foo/bar/bat.txt, the file base is "bat". The method returns the file base component of a path.

: A string containing all information required to uniquely identify a file within a directory. This component is defined as follows:

<file base>{+<extension>}?

The file name component is commonly referred to as a relative file name. In the example path C:/foo/bar/bat.txt, the file name is "bat.txt". The method returns the file name component of a path.

: A string containing all information required to uniquely identify a directory within a file system. This component is defined as follows:

<path root>+<directory name>

The full directory name component is commonly referred to as the absolute directory name. In the example path C:/foo/bar/bat.txt, the full directory name is "C:/foo/bar ".

: A string containing all information required to uniquely identify a file within a file system. This component is defined as follows:

<full directory name>+<directory separator character>+<file name>

The full path component is commonly referred to as the absolute file name. In the example path C:/foo/bar/bat.txt, the full path is "C:/foo/bar/bat.txt". The method returns the full path component.

: A string containing all information required to uniquely identify the highest level in a file system. The component is defined as follows:

{<volume identifier>+<volume separator character>}?+<directory separator character>

In the example path C:/foo/bar/bat.txt , the path root is "C:/". The method returns the component.

: A string composed of a single alphabetic character that uniquely defines a drive or volume in a file system. This component is optional; on systems that do not support volume identifiers, this component is required to be a zero length string. In the example path C:/foo/bar/bat.txt , the path rootis "C:". In the example path, \\myserver\myshare\foo\bar\baz.txt the path root is "\\myserver\myshare".

: A string composed of a single alphabetic character used to separate the from other components in a path. This component can appear in a path only if a volume identifier is present This component is optional; on systems that do not support the volume identifiercomponent, the volume separator character component is required to be a zero length string.

The exact format of a path is determined by the current platform. For example, on Windows systems a path can start with a volume identifier, while this element is not present in Unix system paths. On some systems, paths containing file names can contain extensions. The format of an extension is platform dependent; for example, some systems limit extensions to three characters, while others do not. The current platform and possibly the current file system determine 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 class as well as the exact behavior of some members of the class are determined by the current platform and/or file system.

A path contains either absolute or relative location information. Absolute paths fully specify a location: the file or directory can be uniquely identified regardless of the current location. A full path or full directory name component is present in an absolute path. Relative paths specify a partial location: the current working directory is used as the starting point when locating a file specified with a relative path. To determine the current working directory, call .

Most members of the class do not interact with the file system and do not verify the existence of the file or directory specified by a path string. members that modify a path string, such as , have no effect on files and directories in the file system. members do, however, validate the contents of a specified path string, and throw if the string contains characters that are not valid in path strings, as defined by the current platform and file system. Implementations are required to preserve the case of file and directory path strings, and to be case sensitive if and only if the current platform is case-sensitive.

- Field
  System.Char

  Provides a string containing an alternate single printable non-alphanumeric character used to separate directory levels in a hierarchical file system.

  This field is read-only.

  This field can be set to the same value as .

  and are both valid for separating directory levels in a path string.

  The value of this field is a slash ('/') on Windows systems and a backslash ('\') on Unix systems.

  0
  1.0.5000.0
  2.0.0.0
- Method
  System.String `` `` A containing the path information to modify. A containing the new extension. Specify to remove an existing extension from .

  Changes the extension component of the specified path string.

  A containing the modified path information.

  Platforms that do not support this feature return unmodified.

  The exact behavior of this method is implementation-specific. This method checks for invalid characters as defined by the current platform and file system.

  contains one or more implementation-specific invalid characters. 0 1.0.5000.0 2.0.0.0
- Method
  System.String `` `` A containing the first path. A containing the second path.

  Concatenates two path strings.

  A containing followed by . 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 .

  If does not end with a valid separator character ( or ), is appended to prior to the concatenation.

  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

  0
  1.0.5000.0
  2.0.0.0
- Field
  System.Char

  Provides a string containing a single printable non-alphanumeric character used to separate directory levels in a hierarchical file system.

  This field is read-only.

  and are both valid for separating directory levels in a path string.

  The value of this field is a backslash ('\') on Windows systems and a slash ('/') on Unix systems.

  0
  1.0.5000.0
  2.0.0.0
- Method
  System.String `` A containing the path of a file or directory.

  Returns the directory name component of the specified path string.

  A containing directory information for , or if denotes a root directory, is the empty string, or is Returns if path does not contain directory information.

  The string returned by this method consists of all characters between the first and last or character in . The first separator character is included, but the last separator character is not included in the returned 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

  0
  1.0.5000.0
  2.0.0.0
- Method
  System.String `` A containing the path information from which to get the extension.

  Returns the extension component of the specified path string.

  A containing the extension of , or . If is , returns . If path does not have extension information, returns .

  The extension returned by this method includes the implementation-specific extension separator character used to separate the extension from the rest of the path.

  Platforms that do not support this feature return unmodified.

  The exact behavior of this method is implementation-specific. The character used to separate the extension from the rest of the path is implementation-specific.

  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

  0
  1.0.5000.0
  2.0.0.0
- Method
  System.String `` A containing the path information from which to obtain the filename and extension.

  Returns the file name, including the extension if any, of the specified path string.

  A consisting of the characters after the last directory character in . If the last character of is a directory separator character, returns . If is , returns .

  Platforms that do not support this feature return unmodified.

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

  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 =

  0
  1.0.5000.0
  2.0.0.0
- Method
  System.String `` A containing the path of the file.

  Returns the file base component of the specified path string without the extension.

  A consisting of the string returned by , minus the implementation-specific extension separator character and extension. Platforms that do not support this feature return unmodified.

  For additional details, see .

  contains one or more implementation-specific invalid characters. 0 1.0.5000.0 2.0.0.0
- Method
  System.String `` A containing the file or directory for which to obtain absolute path information.

  Returns information required to uniquely identify a file within a file system.

  A containing the fully qualified (absolute) location of .

  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; however if does exist, the caller is required to have permission to obtain path information for . Note that unlike most members of the class, this method accesses the file system.

  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:\

  0
  1.0.5000.0
  2.0.0.0
- Method
  System.Char[] To be added. To be added. To be added. 2.0.0.0
- Method
  System.Char[] To be added. To be added. To be added. 2.0.0.0
- Method
  System.String `` A containing the path from which to obtain root directory information

  Returns the path root component of the specified path.

  A containing the root directory of , or if is . Returns if the specified path does not contain root information.

  Platforms that do not support this feature return unmodified.

  This method does not verify that the path exists.

  The exact behavior of this method is implementation-specific.

  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

  0
  1.0.5000.0
  2.0.0.0
- Method
  System.String To be added. To be added. To be added. 2.0.0.0
- Method
  System.String

  Returns a unique temporary file name and creates a 0-byte file by that name on disk.

  A containing the name of the temporary file.

  Platforms that do not support this feature return .

  To be added. 0 1.0.5000.0 2.0.0.0
- Method
  System.String

  Returns the path information of a temporary directory.

  A containing the full directory name of a temporary directory.

  The information returned by this method is implementation-specific. Platforms that do not support this feature return .

  On platforms that provide a mechanism for users to discover this information, (for example by checking an environment variable), implementations of the CLI return the same information as the implementation-specific mechanism.

  The caller does not have the required permission. Requires unrestricted access to environment variables. See . 0 1.0.5000.0 2.0.0.0
- Method
  System.Boolean `` A containing the path to search for an extension.

  Returns a indicating whether the specified path includes an extension component.

  if includes a file extension.

  Platforms that do not support this feature return .

  contains one or more implementation-specific invalid characters. 0 1.0.5000.0 2.0.0.0
- Field
  System.Char[] Provides a platform-specific array of characters invalid to use in a path.

  This property is obsolete as of .NET 2.0. Instead you are encouraged to use the and methods.

  1.0.5000.0
  2.0.0.0
  System.Obsolete("see GetInvalidPathChars and GetInvalidFileNameChars methods.")
- Method
  System.Boolean `` A containing the path to test.

  Returns a indicating whether the specified path string contains a path root component.

  if contains an absolute path; if contains relative path information.

  Platforms that do not support this feature return .

  This method does not access file systems or verify the existence of the specified path.

  contains one or more implementation-specific invalid characters. 0 1.0.5000.0 2.0.0.0
- Field
  System.Char

  Provides a implementation-specific separator character used to separate path strings in environment variables.

  This field is read-only.

  0
  1.0.5000.0
  2.0.0.0
- Field
  System.Char To be added. To be added. 1.0.5000.0 2.0.0.0
0 System.Runtime.InteropServices.ComVisible(true)