public static FSEntity New(string aFSEntityName) { FSEntity ret = null; // try { try { DirectoryInfo dir = new DirectoryInfo(aFSEntityName); if (dir.Exists) { ret = new FSEntityDirectory(dir); } else { ret = new FSEntityFile(new FileInfo(aFSEntityName)); } } catch (Exception) { ret = new FSEntityFile(new FileInfo(aFSEntityName)); } } catch (Exception) { } // if (ret == null) { throw new FileNotFoundException("Could not locate suitable entity", aFSEntityName); } // return(ret); }
public static FSEntity New(FSEntity aClone) { FSEntity ret = null; // if (aClone is FSEntityFile) { ret = new FSEntityFile(((FSEntityFile)aClone).File); } else if (aClone is FSEntityDirectory) { ret = new FSEntityDirectory(((FSEntityDirectory)aClone).Directory); } else { throw new ArgumentException("Unsupported File System Entity Type"); } // return(ret); }