/// <summary> /// Initializes a new instance that provides access to the contents /// of a given directory. /// </summary> /// <exception cref="ArgumentNullException">If <paramref name="configuration"/> /// is a null reference.</exception> public LocalFileSystemProvider(LocalFileSystemConfiguration configuration) { Ensure.ArgumentNotNull(configuration, "configuration"); FileSystemConfiguration = configuration; InitTransferServices(); }
/// <summary> /// Creates a configuration for file system providers that provide access to the /// whole local file system of the machine. /// </summary> /// <param name="rootName">An artificial name that is returned as the /// <see cref="VirtualResourceInfo.Name"/> of file system root item /// (as returned by <see cref="IFileSystemProvider.GetFileSystemRoot"/>). /// This property can be set in order to mask the real folder name.</param> /// <exception cref="ArgumentNullException">If <paramref name="rootName"/> /// is a null reference.</exception> /// <returns>Configuration component that can be used to construct a new instance of /// a <see cref="LocalFileSystemProvider"/>.</returns> public static LocalFileSystemConfiguration CreateForMachine(string rootName) { Ensure.ArgumentNotNull(rootName, "rootName"); var configuration = new LocalFileSystemConfiguration { RootName = rootName, DownloadStore = new InMemoryTransferStore <LocalDownloadTransfer>(), UploadStore = new InMemoryTransferStore <LocalUploadTransfer>() }; return(configuration); }
/// <summary> /// 根据目录创建默认配置 /// Creates a configuration for file system providers that limit access to the /// contents of a given directory. /// </summary> /// <param name="rootDirectory">The root folder which is being managed /// by this provider instance.</param> /// <param name="useRelativePaths">If true, returned <see cref="VirtualResourceInfo"/> /// instances do not provide qualified paths, but virtual paths to the submitted /// root directory. This also leverages security in remote access scenarios.</param> /// <exception cref="ArgumentNullException">If <paramref name="rootDirectory"/> or /// is a null reference.</exception> /// <exception cref="DirectoryNotFoundException">If the <paramref name="rootDirectory"/> does /// not exist on the local file system.</exception> /// <returns>Configuration component that can be used to construct a new instance of /// a <see cref="LocalFileSystemProvider"/>.</returns> public static LocalFileSystemConfiguration CreateForRootDirectory(DirectoryInfo rootDirectory, bool useRelativePaths) { Ensure.ArgumentNotNull(rootDirectory, "rootDirectory"); if (!rootDirectory.Exists) { string msg = "Root directory [{0}] does not exist."; msg = String.Format(msg, rootDirectory.FullName); throw new DirectoryNotFoundException(msg); } var configuration = new LocalFileSystemConfiguration { RootDirectory = rootDirectory, UseRelativePaths = useRelativePaths, RootName = rootDirectory.Name, DownloadStore = new InMemoryTransferStore <LocalDownloadTransfer>(), UploadStore = new InMemoryTransferStore <LocalUploadTransfer>() }; return(configuration); }
public LocalFileSystemProvider(string rootName) : this(LocalFileSystemConfiguration.CreateForMachine(rootName)) { }
/// <summary> /// Initializes a new instance that provides access to the contents of a given root /// directory. /// </summary> /// <param name="rootDirectory">The root folder which is being managed /// by this provider instance.</param> /// <param name="useRelativePaths">If true, returned <see cref="VirtualResourceInfo"/> /// instances do not provide qualified paths, but virtual paths to the submitted /// root directory. This also leverages security in remote access scenarios.</param> /// <exception cref="ArgumentNullException">If <paramref name="rootDirectory"/> or /// is a null reference.</exception> /// <exception cref="DirectoryNotFoundException">If the <paramref name="rootDirectory"/> does /// not exist on the local file system.</exception> public LocalFileSystemProvider(DirectoryInfo rootDirectory, bool useRelativePaths) : this(LocalFileSystemConfiguration.CreateForRootDirectory(rootDirectory, useRelativePaths)) { }