public static string GetRandomFileName(string directory) { ChoGuard.ArgumentNotNullOrEmpty(directory, "Directory"); if (!Directory.Exists(directory)) { throw new ChoApplicationException(String.Format("'{0}' directory not found.", directory)); } string fileName = null; do { fileName = Path.Combine(directory, ChoPath.GetRandomFileName()); if (File.Exists(fileName)) { continue; } else { break; } }while (true); return(fileName); }
public static string ToShortName(string longName) { if (longName.IsNullOrWhiteSpace()) { return(longName); } StringBuilder s = new StringBuilder(1000); longName = ChoPath.GetFullPath(longName); uint iSize = (uint)s.Capacity; uint iRet = ChoKernel32.GetShortPathName(longName, s, iSize); return(s.ToString()); }
public static string ToShortFileName(string filePath) { if (filePath.IsNullOrWhiteSpace()) { return(filePath); } StringBuilder s = new StringBuilder(1000); filePath = ChoPath.GetFullPath(filePath); string directory = Path.GetDirectoryName(filePath); string fileName = Path.GetFileName(filePath); uint iSize = (uint)s.Capacity; uint iRet = ChoKernel32.GetShortPathName(directory, s, iSize); return(Path.Combine(s.ToString(), fileName)); }
public static bool IsDirectory(string path) { if (path.IsNullOrWhiteSpace()) { return(false); } path = ChoPath.GetFullPath(path); if (File.Exists(path)) { return(false); } else if (Directory.Exists(path)) { return(true); } else { return(Path.GetExtension(Path.GetFileName(path)).IsNullOrEmpty()); } }