Check Drive Exists(string path)

前端 未结 8 945
半阙折子戏
半阙折子戏 2021-01-03 23:27

How to check the drive is exists in the system from the given string in WPF. I have tried the following

Ex: FileLocation.Text = \"K:\\TestDriv

8条回答
  •  借酒劲吻你
    2021-01-03 23:40

    This is Because Environment.SystemDirectory.XXXXX is all about where the system/windows is installed ...... not for whole HD.

    for this you can use.....

        foreach (var item in System.IO.DriveInfo.GetDrives())
        {
            MessageBox.Show(item.ToString());
        }
    

    it will show all drives including USBs that are attached.....

提交回复
热议问题