You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: xml/System.IO/Path.xml
+12-9Lines changed: 12 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -843,18 +843,21 @@ Unlike the string overload, this method doesn't normalize directory separators.
843
843
</Parameters>
844
844
<Docs>
845
845
<paramname="path">The path of a file or directory.</param>
846
-
<summary>Returns the directory information for the specified path string.</summary>
846
+
<summary>Returns the directory information for the specified path.</summary>
847
847
<returns>Directory information for <paramrefname="path" />, or <seelangword="null" /> if <paramrefname="path" /> denotes a root directory or is null. Returns <seecref="F:System.String.Empty" /> if <paramrefname="path" /> does not contain directory information.</returns>
848
848
<remarks>
849
849
<formattype="text/markdown"><.
855
-
856
-
857
-
851
+
## Remarks
852
+
853
+
In most cases, the string returned by this method consists of all characters in the path up to, but not including, the last directory separator character(s). A directory separator character can be either <xref:System.IO.Path.DirectorySeparatorChar> or <xref:System.IO.Path.AltDirectorySeparatorChar>. If the path consists of a root directory, such as "c:\\", `null` is returned.
854
+
855
+
This method does not support paths using "file:".
856
+
857
+
Because the returned path does not include the last directory separator character(s), passing the returned path back into the <xref:System.IO.Path.GetDirectoryName%2A> method truncates one folder level per subsequent call on the result path. For example, passing the path "C:\Directory\SubDirectory\test.txt" into <xref:System.IO.Path.GetDirectoryName%2A> returns "C:\Directory\SubDirectory". Passing that path, "C:\Directory\SubDirectory", into <xref:System.IO.Path.GetDirectoryName%2A> returns "C:\Directory".
858
+
859
+
For a list of common I/O tasks, see [Common I/O tasks](/dotnet/standard/io/common-i-o-tasks).
860
+
858
861
## Examples
859
862
The following example demonstrates using the `GetDirectoryName` method on a Windows-based desktop platform.
860
863
@@ -868,7 +871,7 @@ Unlike the string overload, this method doesn't normalize directory separators.
In the <seehref="https://go.microsoft.com/fwlink/?LinkID=247912">.NET for Windows Store apps</see> or the <seehref="https://docs.microsoft.com/dotnet/standard/cross-platform/cross-platform-development-with-the-portable-class-library">Portable Class Library</see>, catch the base class exception, <seecref="T:System.IO.IOException" />, instead.
874
+
In <seehref="https://docs.microsoft.com/previous-versions/br230232(v=vs.110)">.NET for Windows Store apps</see> or the <seehref="https://docs.microsoft.com/dotnet/standard/cross-platform/cross-platform-development-with-the-portable-class-library">Portable Class Library</see>, catch the base class exception, <seecref="T:System.IO.IOException" />, instead.
0 commit comments