I have simple TextBox when the user can insert File path.
Now I want to validate if this File path is valid for example:
c:\blabla --> this valid
c: \blabla --> this Not valid
I have this function:
public static bool ValidateFilePath(string path)
{
FileInfo fileInfo = null;
try
{
fileInfo = new FileInfo(path);
}
catch (ArgumentException) { }
catch (PathTooLongException) { }
catch (NotSupportedException) { }
if (fileInfo is null)
return false;
else
return true;
}
But this return True all the time.
Any suggestion or maybe ready c# method that can verify this ?