C# windows form avoid for loop for directory.getlogicaldrives ()
Hello, How to check in all PC hard drives, if a folder exists ? I would like to control at one time and display a message that says yes, find in such disc. In my example, the for condition displays as much message as it finds disk ... How to search without a for loop ? Thank you
Что я уже пробовал:
<pre> string[] str1 = Directory.GetLogicalDrives(); // for (initialization, condition, iteration) for (int i = 0; i < str1.Length; ++i) // MessageBox.Show(str1[i]); if (Directory.Exists(str1[i] + "Dossier1")) { MessageBox.Show("exists in : " + str1[i]); } else { MessageBox.Show("does not exist in : " + str1[i]); }
BillWoodruff
Я предлагаю вам прочитать это: https://blogs.msdn.microsoft.com/jaredpar/2009/12/10/the-file-system-is-unpredictable/
И вот что: https://stackoverflow.com/a/11710169/133321