Replies: 1 comment
-
cc @adamsitnik |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
The behavior of the GetFiles and GetDirectories methods has changed between .NET Framework 4.8 and .NET 6 when using the searchPattern argument. Consider the following code:
DirectoryInfo dirInfo = new DirectoryInfo(@"C:\Temp\");
FileInfo[] files = dirInfo.GetFiles(string.Empty);
DirectoryInfo[] dirs = dirInfo.GetDirectories(string.Empty);
When the above code runs under .NET Framework 4.8 it does not return any files or directories. When the above code runs under .NET 6 it returns all files and all directories.
I believe the .NET Framework behavior is more appropriate since an empty string should try to find matches on files or directories whose name equals an empty string, which there should always be none. .NET 6 is basically treating an empty string as an asterisk wildcard and that does not seem appropriate.
From what I can tell this breaking change is not documented anywhere. Either the original behavior should be returned to .NET 6+ in a patch or this change should be documented.
Beta Was this translation helpful? Give feedback.
All reactions