Class FileSystemProvider
A file system implementation for IVirtualFileProvider.
public class FileSystemProvider : VirtualFileProviderBase, IVirtualFileProvider, IDisposable
- Inheritance
-
FileSystemProvider
- Implements
- Derived
- Inherited Members
- Extension Methods
Constructors
FileSystemProvider(string, string)
Initializes a new instance of the FileSystemProvider class with the given base path.
public FileSystemProvider(string rootPath, string localBasePath)
Parameters
rootPathstringThe root path of this provider.
localBasePathstringThe path to a local directory where this instance will load the files from.
Fields
AltDirectorySeparatorChar
public static readonly char AltDirectorySeparatorChar
Field Value
DirectorySeparatorChar
public static readonly char DirectorySeparatorChar
Field Value
VolumeSeparatorChar
public static readonly char VolumeSeparatorChar
Field Value
Methods
ChangeBasePath(string)
public void ChangeBasePath(string basePath)
Parameters
basePathstring
ConvertFullPathToUrl(string)
protected virtual string ConvertFullPathToUrl(string path)
Parameters
pathstring
Returns
ConvertUrlToFullPath(string)
protected virtual string ConvertUrlToFullPath(string url)
Parameters
urlstring
Returns
CreateDirectory(string)
Creates all directories so that url exists.
public override void CreateDirectory(string url)
Parameters
urlstringThe URL.
DirectoryExists(string)
Determines whether the specified path points to an existing directory.
public override bool DirectoryExists(string url)
Parameters
urlstringThe path.
Returns
FileDelete(string)
Deletes the specified file.
public override void FileDelete(string url)
Parameters
urlstringThe URL.
FileExists(string)
Determines whether the specified path points to an existing file.
public override bool FileExists(string url)
Parameters
urlstringThe path.
Returns
FileMove(string, IVirtualFileProvider, string)
Move the specified file specified from its sourceUrl to the location pointed by destinationUrl in the destination provider. Do not overwrite, throw IOException if the file can't be moved.
public override void FileMove(string sourceUrl, IVirtualFileProvider destinationProvider, string destinationUrl)
Parameters
sourceUrlstringThe source URL.
destinationProviderIVirtualFileProviderThe destination provider.
destinationUrlstringThe destination URL, relative to the destination provider.
FileMove(string, string)
Move the specified file specified from its sourceUrl to the location pointed by destinationUrl. Do not overwrite, throw IOException if the file can't be moved.
public override void FileMove(string sourceUrl, string destinationUrl)
Parameters
FileSize(string)
Returns the size of the specified file in bytes
public override long FileSize(string url)
Parameters
urlstringThe file or directory for which to obtain size
Returns
- long
A long value representing the file size in bytes
GetAbsolutePath(string)
Gets the absolute path for the specified local path from this provider.
public override string GetAbsolutePath(string path)
Parameters
pathstringThe path local to this instance.
Returns
- string
An absolute path.
GetLastWriteTime(string)
Returns the date and time the specified file or directory was last written to.
public override DateTime GetLastWriteTime(string url)
Parameters
urlstringThe file or directory for which to obtain write date and time information.
Returns
- DateTime
A DateTime structure set to the date and time that the specified file or directory was last written to.
ListFiles(string, string, VirtualSearchOption)
Returns the list of files from the specified path.
public override string[] ListFiles(string url, string searchPattern, VirtualSearchOption searchOption)
Parameters
urlstringsearchPatternstringThe search string to match against the names of files in
path. This parameter can contain a combination of valid literal path and wildcard (* and ?) characters, but it doesn't support regular expressions.searchOptionVirtualSearchOptionOne of the enumeration values that specifies whether the search operation should include all subdirectories or only the current directory.
Returns
- string[]
A list of files from the specified path
OpenStream(string, VirtualFileMode, VirtualFileAccess, VirtualFileShare, StreamFlags)
Opens a Stream from the specified path.
public override Stream OpenStream(string url, VirtualFileMode mode, VirtualFileAccess access, VirtualFileShare share = VirtualFileShare.Read, StreamFlags streamType = StreamFlags.None)
Parameters
urlstringmodeVirtualFileModeThe mode.
accessVirtualFileAccessThe access.
shareVirtualFileShareThe process sharing mode.
streamTypeStreamFlags
Returns
- Stream
The opened stream.
TryGetFileLocation(string, out string, out long, out long)
Gets the absolute path and location if the specified path physically exist on the disk in an uncompressed form (could be inside another file).
public override bool TryGetFileLocation(string path, out string filePath, out long start, out long end)
Parameters
pathstringThe path.
filePathstringThe file containing the data.
startlongThe start offset in the file.
endlongThe end offset in the file (can be -1 if full file).
Returns
- bool
True if success, false if not supported and entry is found (note: even when true, the file might not actually exists).