簡體   English   中英

使用C#檢查客戶端計算機的任何驅動器中是否存在目錄

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

一個用戶在其計算機的C驅動器中具有目錄,而另一個用戶在E驅動器中具有目錄。

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

我必須通過從路徑\\ SoonrWorkplace \\ ABC \\ Clients跳出驅動器名稱來檢查目錄是否存在

這是代碼

    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"

您應該檢出Directory.Exsists()

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM