private DirectoryInfo CreateSubdirectoryCore(string path, string templatePath, ObjectSecurity directorySecurity, bool compress) { string pathLp = Path.CombineCore(false, LongFullName, path); string templatePathLp = templatePath == null ? null : Path.GetExtendedLengthPathCore(Transaction, templatePath, PathFormat.RelativePath, GetFullPathOptions.TrimEnd | GetFullPathOptions.RemoveTrailingDirectorySeparator); if (string.Compare(LongFullName, 0, pathLp, 0, LongFullName.Length, StringComparison.OrdinalIgnoreCase) != 0) { throw new ArgumentException(Resources.Invalid_Subpath, "path"); } return(Directory.CreateDirectoryCore(Transaction, pathLp, templatePathLp, directorySecurity, compress, PathFormat.LongFullPath)); }
private T NewFileSystemEntryType <T>(NativeMethods.WIN32_FIND_DATA win32FindData, string fileName, string pathLp, bool isFolder) { // Determine yield. if (FileSystemObjectType != null && (!(bool)FileSystemObjectType || !isFolder) && (!(bool)!FileSystemObjectType || isFolder)) { return((T)(object)null); } var fullPathLp = string.Format(CultureInfo.InvariantCulture, "{0}{1}", pathLp, fileName ?? string.Empty); // Return object instance FullPath property as string, optionally in long path format. if (AsString) { return((T)(object)(IsRelativePath ? fullPathLp : (AsLongPath ? fullPathLp : Path.GetRegularPathCore(fullPathLp, GetFullPathOptions.None, false)))); } // Make sure the requested file system object type is returned. // null = Return files and directories. // true = Return only directories. // false = Return only files. var fsei = new FileSystemEntryInfo(win32FindData) { FullPath = !fullPathLp.StartsWith(Path.CurrentDirectoryPrefix, StringComparison.OrdinalIgnoreCase) ? fullPathLp : Path.CombineCore(false, InputPath, fileName) }; return(AsFileSystemInfo // Return object instance of type FileSystemInfo. ? (T)(object)(fsei.IsDirectory ? (FileSystemInfo) new DirectoryInfo(Transaction, fsei.LongFullPath, PathFormat.LongFullPath) { EntryInfo = fsei } : new FileInfo(Transaction, fsei.LongFullPath, PathFormat.LongFullPath) { EntryInfo = fsei }) // Return object instance of type FileSystemEntryInfo. : (T)(object)fsei); }