public string CreateDirectory(string ownerName, string directoryName) { string pathName = sharedFolder.FullName + Config.SLASH + directoryName; DirectoryInfo info = new DirectoryInfo(pathName); if (!info.Exists) { info.Create(); FileInfo dirInfor = new FileInfo(pathName + Config.SLASH + INFOR_FILE); FileStream stream = dirInfor.Open(FileMode.Create, FileAccess.Write); try { IFormatter formatter = new BinaryFormatter(); DirectoryInformation infor = new DirectoryInformation(null, directoryName, ownerName); formatter.Serialize(stream, infor); stream.Close(); } catch { if (stream != null) { try { stream.Close(); } catch { } } info.Delete(true); return null; } } return directoryName; }
public string CreateDirectory(string ownerName, string pathName, string directoryName) { if (pathName == null || pathName == String.Empty) { throw new ArgumentException("pathname cannot be null or empty."); } string viewPathName = pathName + Config.SLASH + directoryName; pathName = sharedFolder.FullName + Config.SLASH + viewPathName; DirectoryInfo info = new DirectoryInfo(pathName); if (!info.Exists) { info.Create(); FileInfo dirInfor = new FileInfo(pathName + Config.SLASH + INFOR_FILE); FileStream stream = dirInfor.Open(FileMode.Create, FileAccess.Write); try { IFormatter formatter = new BinaryFormatter(); DirectoryInformation infor = new DirectoryInformation(info.Parent.FullName, directoryName, ownerName); formatter.Serialize(stream, infor); stream.Close(); } catch { if (stream != null) { try { stream.Close(); } catch { } } info.Delete(true); return null; } return viewPathName; } return null; }