My code here var fullPath = Path.GetFullPath(input);
throws OutOfMemoryException Insufficient memory to continue the execution of the program when I pass this value "\\." as argument. Any explanation as to why Path.GetFullPath("\\.")
crashes?
XAML:
<TextBox><TextBox.Text><Binding Path="FolderPath" Mode="TwoWay" UpdateSourceTrigger="PropertyChanged" ValidatesOnDataErrors="True" NotifyOnValidationError="True"/></TextBox.Text></TextBox>
ViewModel:
// Implementation of IDataErrorInfo
public string this[string columnName]
{
get
{
if (columnName != null)
{
if (columnName.Equals(nameof(FolderPath)))
{
if(!Validator.IsValidPath(FolderPath)
return "Invalid Folder";
}
}
}
}
Validator Class:
private static bool IsValidPath(string input)
{
bool isValid = false;
try
{
var fullPath = Path.GetFullPath(input);
return input.Equals(fullPath, StringComparison.InvariantCultureIgnoreCase);
}
catch (Exception)
{
isValid = false;
}
return isValid;
}