public VolumeInfo(string volumeName) { if (Utils.IsNullOrWhiteSpace(volumeName)) { throw new ArgumentNullException("volumeName"); } if (!volumeName.StartsWith(Path.LongPathPrefix, StringComparison.OrdinalIgnoreCase)) { volumeName = Path.IsUncPathCore(volumeName, false, false) ? Path.GetLongPathCore(volumeName, GetFullPathOptions.None) : Path.LongPathPrefix + volumeName; } else { if (volumeName.Length == 1) { volumeName += Path.VolumeSeparatorChar; } else if (!volumeName.StartsWith(Path.GlobalRootPrefix, StringComparison.OrdinalIgnoreCase)) { volumeName = Path.GetPathRoot(volumeName, false); } } if (Utils.IsNullOrWhiteSpace(volumeName)) { throw new ArgumentException("Argument must be a drive letter (\"C\"), RootDir (\"C:\\\") or UNC path (\"\\\\server\\share\")"); } Name = Path.AddTrailingDirectorySeparator(volumeName, false); _volumeHandle = null; }
public VolumeInfo(string volumeName) { if (Utils.IsNullOrWhiteSpace(volumeName)) { throw new ArgumentNullException("volumeName"); } if (!volumeName.StartsWith(Path.LongPathPrefix, StringComparison.Ordinal)) { volumeName = Path.IsUncPathCore(volumeName, false, false) ? Path.GetLongPathCore(volumeName, GetFullPathOptions.None) : Path.LongPathPrefix + volumeName; } else { volumeName = volumeName.Length == 1 ? volumeName + Path.VolumeSeparatorChar : Path.GetPathRoot(volumeName, false); if (!volumeName.StartsWith(Path.GlobalRootPrefix, StringComparison.OrdinalIgnoreCase)) { volumeName = Path.GetPathRoot(volumeName, false); } } if (Utils.IsNullOrWhiteSpace(volumeName)) { throw new ArgumentException(Resources.InvalidDriveLetterArgument, "volumeName"); } Name = Path.AddTrailingDirectorySeparator(volumeName, false); _volumeHandle = null; }
private DirectoryInfo(KernelTransaction transaction, string fullPath, bool junk1, bool junk2) { IsDirectory = true; Transaction = transaction; LongFullName = Path.GetLongPathCore(fullPath, GetFullPathOptions.None); OriginalPath = Path.GetFileName(fullPath, true); FullPath = fullPath; DisplayPath = OriginalPath.Length != 2 || OriginalPath[1] != Path.VolumeSeparatorChar ? OriginalPath : Path.CurrentDirectoryPrefix; }