-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Wrong Path returned by DirectoryInfo.FullName #63892
Comments
Tagging subscribers to this area: @dotnet/area-system-io Issue DetailsDescriptionI have an application which contains the following code line: string foo = new DirectoryInfo("c:").FullName; The string Reproduction Steps
using System.IO;
using System;
Console.WriteLine("current dir: " + Directory.GetCurrentDirectory());
foreach (string path in new[] {
"d:",
"d:/",
"d:\\",
"c:",
"c:/",
"c:\\",
})
Console.WriteLine($" {path,5} ---> {new DirectoryInfo(path).FullName}");
C:\> dotnet --list-sdks
3.1.416 [C:\Program Files\dotnet\sdk]
6.0.200-preview.21617.4 [C:\Program Files\dotnet\sdk]
Expected behaviorExpected output:
Actual behaviorActual output:
Regression?I do not think that this bug occured in a previous version. Known WorkaroundsI could check whether the path exactly matches ConfigurationI am using .NET Other informationNo response
|
Hello @Unknown6656 this seems to be original behavior:
On Windows, "X:" means "current directory on the X drive". Our implementation ultimately calls GetFullPathName which gives the example "If you specify "U:" the path returned is the current directory on the "U:" drive". If you want the behavior you describe, your workaround sounds like a good one. thanks for opening the issue! |
Hello @danmoseley, |
Description
I have an application which contains the following code line:
The string
"c:"
is user-provided and may be a longer path. If the user passes a path consisting only of the drive label and the colon (while omitting the finishing forward or backward slash) and the drive is the one matching the drive of the current execution directory, then the execution directory is returned instead of the root drive.Reproduction Steps
subst
cmd command.net6.0-windows
. I use the following version:C:\> dotnet --list-sdks 3.1.416 [C:\Program Files\dotnet\sdk] 6.0.200-preview.21617.4 [C:\Program Files\dotnet\sdk]
c:/
).Expected output
Actual output
Regression?
I do not think that this bug occured in a previous version.
Known Workarounds
I could check whether the path exactly matches
^[a-z]:$
and append a/
if that is the case.Configuration
I am using .NET
6.0.200-preview.21617.4
on Windows 11 Pro 64Bit:The text was updated successfully, but these errors were encountered: