Check Drive Exists(string path)

前端 未结 8 947
半阙折子戏
半阙折子戏 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条回答
  •  -上瘾入骨i
    2021-01-03 23:57

    you can do follow

    bool isDriveExists(string driveLetterWithColonAndSlash)
    {
        return DriveInfo.GetDrives().Any(x => x.Name == driveLetterWithColonAndSlash);
    }
    

提交回复
热议问题