mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Fix GetCorrectCasedPath() to first check if any system file entries is returned before calling First() (#10930)
This commit is contained in:
@@ -155,7 +155,17 @@ namespace Microsoft.PowerShell.Commands
|
||||
}
|
||||
else
|
||||
{
|
||||
exactPath = Directory.GetFileSystemEntries(exactPath, item).First();
|
||||
// Use GetFileSystemEntries to get the correct casing of this element
|
||||
var entries = Directory.GetFileSystemEntries(exactPath, item);
|
||||
if (entries.Length > 0)
|
||||
{
|
||||
exactPath = entries.First();
|
||||
}
|
||||
else
|
||||
{
|
||||
// If previous call didn't return anything, something failed so we just return the path we were given
|
||||
return path;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user