-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Description
Type of issue
Other (describe below)
Description
In the examples for Path.GetRelativePath, there is the following:
[…]
Console.WriteLine(Path.GetRelativePath("C:/Program Files/Common Files", "C:/Program Files/Microsoft"));
[…]
// This code produces output similar to the following:
//
// ../Microsoft
[…]
In other words, it's saying that the output will use a forward slash, at least if the inputs to the function uses forward slashes (on Windows, since those are clearly Windows paths). However when running that myself on Windows I get ..\Microsoft
, contradicting the example code.
This means e.g. that this does not work on Windows: https://stackoverflow.com/a/66877016, as there will be ..\
instead of ../
, whereas that code would work if Path.GetRelativePath gave results like what is written in the example code.
Page URL
https://learn.microsoft.com/en-us/dotnet/api/system.io.path.getrelativepath?view=net-8.0
Content source URL
https://github.com/dotnet/dotnet-api-docs/blob/main/xml/System.IO/Path.xml
Document Version Independent Id
96559f6f-99cb-6994-6dde-7fcae426fe46
Platform Id
85c93c86-ec19-1615-1f5b-76ab8e1e089a