Skip to content

Commit 7e69b7f

Browse files
authored
Clarify GetDirectoryName remarks (#5060)
1 parent 5202cd1 commit 7e69b7f

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

xml/System.IO/Path.xml

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -843,18 +843,21 @@ Unlike the string overload, this method doesn't normalize directory separators.
843843
</Parameters>
844844
<Docs>
845845
<param name="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>
847847
<returns>Directory information for <paramref name="path" />, or <see langword="null" /> if <paramref name="path" /> denotes a root directory or is null. Returns <see cref="F:System.String.Empty" /> if <paramref name="path" /> does not contain directory information.</returns>
848848
<remarks>
849849
<format type="text/markdown"><![CDATA[
850850
851-
## Remarks
852-
In most cases, the string returned by this method consists of all characters in the path up to but not including the last <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. Note that this method does not support paths using "file:". Because the returned path does not include the <xref:System.IO.Path.DirectorySeparatorChar> or <xref:System.IO.Path.AltDirectorySeparatorChar>, passing the returned path back into the <xref:System.IO.Path.GetDirectoryName%2A> 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 <xref:System.IO.Path.GetDirectoryName%2A> method will return "C:\Directory\SubDirectory". Passing that string, "C:\Directory\SubDirectory", into <xref:System.IO.Path.GetDirectoryName%2A> will result in "C:\Directory".
853-
854-
For a list of common I/O tasks, see [Common I/O Tasks](/dotnet/standard/io/common-i-o-tasks).
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+
858861
## Examples
859862
The following example demonstrates using the `GetDirectoryName` method on a Windows-based desktop platform.
860863
@@ -868,7 +871,7 @@ Unlike the string overload, this method doesn't normalize directory separators.
868871
<exception cref="T:System.IO.PathTooLongException">
869872
<block subset="none" type="note">
870873
<para>
871-
In the <see href="https://go.microsoft.com/fwlink/?LinkID=247912">.NET for Windows Store apps</see> or the <see href="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, <see cref="T:System.IO.IOException" />, instead.
874+
In <see href="https://docs.microsoft.com/previous-versions/br230232(v=vs.110)">.NET for Windows Store apps</see> or the <see href="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, <see cref="T:System.IO.IOException" />, instead.
872875

873876
</para>
874877
</block>

0 commit comments

Comments
 (0)