private FileInfo ConvertTextToFileInfo() { FileInfo newFileInfo = null; if (Text.Equals(string.Empty)) { ParameterError newError = new ParameterError(ParameterErrorTypes.TextWasEmpty); newError.Name = Name; errors.Add(newError); } else if (File.Exists(text)) { try { newFileInfo = new FileInfo(text); } catch (Exception e) { IOError newError = new IOError(IOErrorTypes.FileInfoInstanceException); newError.Name = Name; newError.Exception = e; errors.Add(newError); } } else { IOError newError = new IOError(IOErrorTypes.FileDoesNotExist); newError.Name = Name; errors.Add(newError); } return newFileInfo; }
private DirectoryInfo ConvertTextToDirectoryInfo() { DirectoryInfo newDirInfo = null; if (Directory.Exists(text)) { try { newDirInfo = new DirectoryInfo(text); } catch (Exception e) { IOError newError = new IOError(IOErrorTypes.DirInfoInstanceException); newError.Name = Name; newError.Exception = e; errors.Add(newError); } } else { IOError newError = new IOError(IOErrorTypes.DirectoryDoesNotExist); newError.Name = Name; errors.Add(newError); } if (newDirInfo == null) { newDirInfo = new DirectoryInfo(Environment.GetFolderPath(Environment.SpecialFolder.Desktop)); } return newDirInfo; }