private bool IsValidFullPathFilename(string path, bool filemustexist)
{
bool validDir, validFile;
string message = string.Empty;
string dir = Path.GetDirectoryName(path);
string filename = Path.GetFileName(path);
///Check filename
if (filemustexist && !File.Exists(path))// || (File.GetAttributes(path) & FileAttributes.Directory) == FileAttributes.Directory)
{
validFile = false;
message = "Invalid Filename! " + filename;
}
else
validFile = true;
//// Check Directory path
if (Directory.Exists(dir) || dir.Trim().Length == 0)// valid folder or blank if defaults are needed
{
validDir = true;
}
else
{
message = message + " Invalid Directory path! " + dir;
validDir = false;
}
if (message.Trim().Length > 0)
{
logService.Warn(message);
}
return (validDir && validFile);
}