c# - Check is windows drive exists -


i'm going write c# code checks c,d,e... (windows disk drive) exists, or not? , find drive exists in client windows, copy there files.

i want write code similar following logic:

if ( !exist(drive "c:\" ) ) {    if ( !exist(drive "d:\" ) )    {       if ( !exist(drive "e:\" ) )       {          ...          search fined existence drive          copy file path of existence drive       }    } } 

try this:

   //get drive names driveinfo.getdrives()  var drives= driveinfo.getdrives();         foreach (var item in drives)        {            //do        } 

edited(check exist)

   var drives= driveinfo.getdrives();        if (drives.where(data => data.name == "c:\\").count() == 1 &&            drives.where(data => data.name == "d:\\").count() == 1 &&            drives.where(data => data.name == "e:\\").count() == 1)        {         } 

Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -