简体   繁体   中英

checking if a directory exists in any drive of a client machine using c#

a user has a directory in C drive of his computer and another user has directory in E drive.

user A:E:\SoonrWorkplace\Clients
user B: E:\SoonrWorkplace\ABC\Clients

i have to check if the directory exists by tripping drive name from the path ie \\SoonrWorkplace\\ABC\\Clients

here is the code

    if (!string.IsNullOrEmpty(txtClientRootFolder.Text))
            {
                string Filepath = txtClientRootFolder.Text.Trim();

                if (Directory.Exists(Filepath))
                {
                    checkClientRootFolder.Visible = true;
                    imgstatus.ImageUrl = "~/Images/tick.png";
                }
                else
                {
                    checkClientRootFolder.Visible = true;
                    imgstatus.ImageUrl = "~/Images/remove.png";
                }


            }

where Filepath="\SoonrWorkplace\ABC\Clients"

You should check out Directory.Exsists()

  if(Directory.Exists("Your file path")) 
   {
     //Do something 
   }     

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM