Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
958 views
in Technique[技术] by (71.8m points)

directory - c# - EnumerateDirectories catch exception even with IgnoreInaccessible property

I tried to enumerate all subdirectories of a very huge shared folder (behind a DFS root). This code works fine, when it tries to access an unauthorized subdirectories, enumeration continue :

List<string> dirs = new List<string>(Directory.EnumerateDirectories("\mydfssharemyrootfolder", "*", new EnumerationOptions
{
    IgnoreInaccessible = true,
    RecurseSubdirectories = true
}));

But for a specific folder it gives me this exception and stop enumeration :

System.IO.IOException: Erreur réseau inattendue. : '\mydfssharemyrootfolderCertification'
   at System.IO.Enumeration.FileSystemEnumerator`1.FindNextEntry()
   at System.IO.Enumeration.FileSystemEnumerator`1.DirectoryFinished()
   at System.IO.Enumeration.FileSystemEnumerator`1.FindNextEntry()
   at System.IO.Enumeration.FileSystemEnumerator`1.MoveNext()
   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
   at extractAcl.Program.Main(String[] args) in Program.cs:line 58

I'm not allowed to read this folder but like many others. IgnoreInaccessible property works for many others unauthorized folders and i don't get why an exception occurs for this specific one. If i tried to browse it from my laptop i get this message :

first message

If i tried to browse it directly on file server i get this message :

second message

I would like to bypass this folder and continue enumeration

question from:https://stackoverflow.com/questions/65833225/c-sharp-enumeratedirectories-catch-exception-even-with-ignoreinaccessible-prop

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...