简体   繁体   English

使用C#检查客户端计算机的任何驱动器中是否存在目录

[英]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. 一个用户在其计算机的C驱动器中具有目录,而另一个用户在E驱动器中具有目录。

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 我必须通过从路径\\ 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() 您应该检出Directory.Exsists()

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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