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
Clarify Path.GetPathRoot return value when path is effectively empty (#3233)
* Clarify Path.GetPathRoot return value when path is effectively empty
* Add extra details from original issue's discussion
* missed a paramref
* suggestions by rpetrusha
Co-Authored-By: Ron Petrusha <[email protected]>
* Bring back exception, mention it is only thrown in Framework.
* spacing
* spacing
* Update Path.xml
* Update xml/System.IO/Path.xml
Co-Authored-By: Maira Wenzel <[email protected]>
* add missing period
<paramname="path">The path from which to obtain root directory information.</param>
1405
+
<paramname="path">A read-only span of characters containing the path from which to obtain root directory information.</param>
1406
1406
<summary>Gets the root directory information from the path contained in the specified character span.</summary>
1407
-
<returns>A character span containing the root directory of `path`.</returns>
1407
+
<returns>A read-only span of characters containing the root directory of <paramrefname="path" />.</returns>
1408
1408
<remarks>
1409
1409
<formattype="text/markdown"><. For a list of common I/O tasks, see [Common I/O Tasks](~/docs/standard/io/common-i-o-tasks.md).
1439
+
1440
+
1415
1441
]]></format>
1416
1442
</remarks>
1417
1443
<relatedtype="article"href="~/docs/standard/io/file-path-formats.md">File path formats on Windows systems</related>
@@ -1457,47 +1483,64 @@ Unlike the string overload, this method doesn't normalize directory separators.
1457
1483
<ParameterName="path"Type="System.String" />
1458
1484
</Parameters>
1459
1485
<Docs>
1460
-
<paramname="path">The path from which to obtain root directory information.</param>
1461
-
<summary>Gets the root directory information of the specified path.</summary>
1462
-
<returns>The root directory of <paramrefname="path" />, or <seelangword="null" /> if <paramrefname="path" /> is <seelangword="null" />, or an empty string if <paramrefname="path" /> does not contain root directory information.</returns>
1486
+
<paramname="path">A string containing the path from which to obtain root directory information.</param>
1487
+
<summary>Gets the root directory information from the path contained in the specified string.</summary>
1488
+
<returns>The root directory of <paramrefname="path" /> if it is rooted.
1489
+
1490
+
-or-
1491
+
1492
+
<seecref="P:System.String.Empty" /> if <paramrefname="path" /> does not contain root directory information.
1493
+
1494
+
-or-
1495
+
1496
+
<seelangword="null" /> if <paramrefname="path" /> is <seelangword="null" /> or is effectively empty.</returns>
1463
1497
<remarks>
1464
-
<formattype="text/markdown"><. For a list of common I/O tasks, see [Common I/O Tasks](~/docs/standard/io/common-i-o-tasks.md).
1484
-
1485
-
## Examples
1486
-
The following example demonstrates a use of the `GetPathRoot` method.
This method does not verify that the path or file exists.
1503
+
1504
+
This method will normalize directory separators.
1505
+
1506
+
A string is "effectively empty" if:
1507
+
1508
+
- In Windows, calling `IsEmpty` on this string returns `true`, or all its characters are spaces (' ').
1509
+
- In Unix, calling <xref:System.String.IsNullOrEmpty%2A> on this string returns `true`.
1510
+
1511
+
Possible patterns for the string returned by this method are as follows:
1512
+
1513
+
- `null` (`path` was null or an empty string).
1514
+
1515
+
- An empty string (`path` specified a relative path on the current drive or volume).
1516
+
1517
+
- "\" (Unix: `path` specified an absolute path on the current drive).
1518
+
1519
+
- "X:" (Windows: `path` specified a relative path on a drive, where *X* represents a drive or volume letter).
1520
+
1521
+
- "X:\" (Windows: `path` specified an absolute path on a given drive).
1522
+
1523
+
- "\\\ComputerName\SharedFolder" (Windows: a UNC path).
1524
+
1525
+
- "\\\\\?\C:" (Windows: a DOS device path, supported in .NET Core 1.1 and later versions, and in .NET Framework 4.6.2 and later versions).
1526
+
1527
+
For more information on file paths on Windows, see [File path formats on Windows systems](~/docs/standard/io/file-path-formats.md). For a list of common I/O tasks, see [Common I/O Tasks](~/docs/standard/io/common-i-o-tasks.md).
1528
+
1529
+
## Examples
1530
+
The following example demonstrates a use of the `GetPathRoot` method.
<paramrefname="path" /> contains one or more of the invalid characters defined in <seecref="M:System.IO.Path.GetInvalidPathChars" />.
1496
-
1497
-
-or-
1498
-
1499
-
<seecref="F:System.String.Empty" /> was passed to <paramrefname="path" />.</exception>
1500
-
<relatedtype="article"href="~/docs/standard/io/file-path-formats.md">File path formats on Windows systems</related>
1538
+
<exceptioncref="T:System.ArgumentException">.NET Framework only: <paramrefname="path" /> contains one or more of the invalid characters defined in <seecref="M:System.IO.Path.GetInvalidPathChars" />.
1539
+
1540
+
-or-
1541
+
1542
+
.NET Framework only: <seecref="F:System.String.Empty" /> was passed to <paramrefname="path" />.</exception>
1543
+
<relatedtype="Article"href="~/docs/standard/io/file-path-formats.md">File path formats on Windows systems</related>
1501
1544
<relatedtype="Article"href="~/docs/standard/io/index.md">File and Stream I/O</related>
1502
1545
<relatedtype="Article"href="~/docs/standard/io/how-to-read-text-from-a-file.md">How to: Read Text from a File</related>
1503
1546
<relatedtype="Article"href="~/docs/standard/io/how-to-write-text-to-a-file.md">How to: Write Text to a File</related>
0 commit comments