-
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
(Error .Net Core 5) "Directory.GetDirectories("D:")" returns not existingDirectory #68503
Comments
Tagging subscribers to this area: @dotnet/area-system-io Issue DetailsThis issue has been moved from a ticket on Developer Community.
There is another theme with this error, but it closed: Original CommentsFeedback Bot on 3/21/2022, 00:32 AM:(private comment, text removed)
|
I tested the code below and got an amazing result: using System;
using System.IO;
for(int i = 0;i < 20; i++)
{
string s = (char)('A' + i) + ":";
Console.WriteLine(s + " -> " + Path.GetFullPath(s));
} Output:
|
This is called a drive relative path and it's why the backslash in |
I read the article but still don't understand what happened exactly. And I think the behavior in this issue is definitely unexpected. Update: I understand my case now and believe |
I think you're right. Returning the |
I wonder if this bug is specific to Windows 8.1, in such case it would probably be tied to the Windows API, not to .NET.
|
@jozkee I did repro the |
@skyoxZ yes please, could you please also add |
@jozkee Please try the code below: string foo = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "foo");
string bar = Path.Combine(foo, "bar");
Directory.CreateDirectory(bar);
Environment.CurrentDirectory = foo;
string root = foo.Remove(2);
string[] ss = Directory.GetDirectories(root);
Console.WriteLine("-- " + root);
foreach(string s in ss)
{
Console.WriteLine(s);
} .NET Framework 4.8 got correct result:
however, .NET 6.0 got the result below:
|
Fixes #68503 On netfx we were concatenating user directories ending with volume separator `:` instead of joining with a path separator `\`. That is not the case in .NET [core]. This change brings that back as it is incorrect to join paths like "C:" with a separator in between the enumerated entries as the meaning of "relative to drive's CWD" gets lost.
This issue has been moved from a ticket on Developer Community.
There is another theme with this error, but it closed:
https://developercommunity2.visualstudio.com/t/DirectoryGetDirectoriesdrive-return-a/175411?entry=suggestion&space=8&preview2=true
Original Comments
Feedback Bot on 3/21/2022, 00:32 AM:
(private comment, text removed)
The text was updated successfully, but these errors were encountered: