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:\TestDrive\XXX";
if (!Directory.Exists(FileLocation.Text))
{
MessageBox.Show("Invalid Directory", "Error", MessageBoxButton.OK);
return;
}
It is checking full path but it should check "K:\" from the text
. Could you please guide me
EDIT 1: "K:\TestDrive\XXX" is not static
EDIT 2: I tried the below, in my system i'm having 3 drives C, D and E
but it showing false.
Environment.SystemDirectory.Contains("D").ToString(); = "False"