During Tab Completion, skip file if can't read file attributes (#10910)

This commit is contained in:
Steve Lee
2019-10-28 08:28:47 +05:00
committed by Ilya
parent ca1b6fb4c5
commit 2746cb7b89
@@ -4275,10 +4275,17 @@ namespace System.Management.Automation
continue;
var fileInfo = new FileInfo(entry);
if ((fileInfo.Attributes & FileAttributes.Hidden) != 0)
try
{
PSObject wrapper = PSObject.AsPSObject(entry);
psobjs.Add(wrapper);
if ((fileInfo.Attributes & FileAttributes.Hidden) != 0)
{
PSObject wrapper = PSObject.AsPSObject(entry);
psobjs.Add(wrapper);
}
}
catch
{
// do nothing if can't get file attributes
}
}
}