Class VirtualFileSystem
Virtual abstraction over a file system. It handles access to files, http, packages, path rewrite, etc...
public static class VirtualFileSystem
- Inheritance
-
VirtualFileSystem
Fields
AllDirectorySeparatorChars
public static readonly char[] AllDirectorySeparatorChars
Field Value
- char[]
AltDirectorySeparatorChar
public static readonly char AltDirectorySeparatorChar
Field Value
ApplicationBinary
The application binary folder.
public static readonly IVirtualFileProvider ApplicationBinary
Field Value
ApplicationCache
The application cache folder.
public static readonly IVirtualFileProvider ApplicationCache
Field Value
ApplicationData
The application data file provider.
public static readonly IVirtualFileProvider ApplicationData
Field Value
ApplicationDatabase
The application database file provider (Index level).
public static readonly IVirtualFileProvider ApplicationDatabase
Field Value
ApplicationDatabaseIndexName
public static readonly string ApplicationDatabaseIndexName
Field Value
ApplicationDatabaseIndexPath
public static readonly string ApplicationDatabaseIndexPath
Field Value
ApplicationDatabasePath
public static readonly string ApplicationDatabasePath
Field Value
ApplicationLocal
The application user local folder. Included in backup.
public static readonly IVirtualFileProvider ApplicationLocal
Field Value
ApplicationObjectDatabase
The application database file provider (ObjectId level).
public static IVirtualFileProvider ApplicationObjectDatabase
Field Value
ApplicationRoaming
The application user roaming folder. Included in backup.
public static readonly IVirtualFileProvider ApplicationRoaming
Field Value
ApplicationTemporary
The application temporary data provider.
public static readonly IVirtualFileProvider ApplicationTemporary
Field Value
DirectorySeparatorChar
public static readonly char DirectorySeparatorChar
Field Value
Drive
The whole host file system. This should be used only in tools.
public static readonly DriveFileProvider Drive
Field Value
LocalDatabasePath
public static readonly string LocalDatabasePath
Field Value
Properties
Providers
Gets the registered providers.
public static IEnumerable<IVirtualFileProvider> Providers { get; }
Property Value
- IEnumerable<IVirtualFileProvider>
The providers.
Methods
BuildPath(string, string)
public static string BuildPath(string path, string relativePath)
Parameters
Returns
Combine(string, string)
Combines the specified paths. Similiar to Combine(string, string).
public static string Combine(string path1, string path2)
Parameters
Returns
- string
The combined path.
CreateDirectory(string)
Creates all directories so that path exists.
public static void CreateDirectory(string path)
Parameters
path
stringThe path.
CreateRelativePath(string, string)
Creates the relative path that can access to target
from sourcePath
.
public static string CreateRelativePath(string target, string sourcePath)
Parameters
Returns
- string
The relative path.
DirectoryExists(string)
Checks the existence of a directory.
public static bool DirectoryExists(string path)
Parameters
path
stringThe path of the directory to check.
Returns
- bool
True if the directory exists, false otherwise.
FileDelete(string)
public static void FileDelete(string path)
Parameters
path
string
FileExists(string)
Checks the existence of a file.
public static bool FileExists(string path)
Parameters
path
stringThe path of the file to check.
Returns
- bool
True if the file exists, false otherwise.
FileExistsAsync(string)
public static Task<bool> FileExistsAsync(string path)
Parameters
path
string
Returns
FileMove(string, string)
public static void FileMove(string sourcePath, string destinationPath)
Parameters
FileSize(string)
public static long FileSize(string path)
Parameters
path
string
Returns
GetAbsolutePath(string)
Gets the absolute path (system dependent) for the specified path in the context of the virtual file system.
public static string GetAbsolutePath(string path)
Parameters
path
stringThe path local to the virtual file system.
Returns
- string
An absolute path (system dependent .i.e C:\Path\To\Your\File.x).
GetFileName(string)
Gets the file's name with its extension ("/path/to/file/fileName.ext"->"fileName.ext")
public static string GetFileName(string path)
Parameters
path
stringpath containing file's path and name
Returns
- string
The name of the file with its extension
GetLastWriteTime(string)
public static DateTime GetLastWriteTime(string path)
Parameters
path
string
Returns
GetParentFolder(string)
Gets the parent folder.
public static string GetParentFolder(string path)
Parameters
path
stringThe path.
Returns
- string
The parent folder.
Exceptions
- ArgumentNullException
path
- ArgumentException
path doesn't contain a /;path
GetTempFileName()
Creates a temporary zero-byte file and returns its full path.
public static string GetTempFileName()
Returns
- string
The full path of the created temporary file.
ListFiles(string, string, VirtualSearchOption)
Lists the files matching a pattern in a specified directory.
public static Task<string[]> ListFiles(string path, string searchPattern, VirtualSearchOption searchOption)
Parameters
path
stringThe path.
searchPattern
stringThe search pattern.
searchOption
VirtualSearchOptionThe search option.
Returns
MountFileSystem(string, string)
Mounts the specified path in the specified virtual file mount point.
public static IVirtualFileProvider MountFileSystem(string mountPoint, string path)
Parameters
Returns
OpenStream(string, VirtualFileMode, VirtualFileAccess, VirtualFileShare)
Opens the stream from a given path.
public static Stream OpenStream(string path, VirtualFileMode mode, VirtualFileAccess access, VirtualFileShare share = VirtualFileShare.Read)
Parameters
path
stringThe path.
mode
VirtualFileModeThe stream opening mode (append, open, create, etc...).
access
VirtualFileAccessThe stream access.
share
VirtualFileShareThe stream share mode.
Returns
- Stream
The stream.
OpenStream(string, VirtualFileMode, VirtualFileAccess, VirtualFileShare, out IVirtualFileProvider)
Opens the stream from a given path.
public static Stream OpenStream(string path, VirtualFileMode mode, VirtualFileAccess access, VirtualFileShare share, out IVirtualFileProvider provider)
Parameters
path
stringThe path.
mode
VirtualFileModeThe stream opening mode (append, open, create, etc...).
access
VirtualFileAccessThe stream access.
share
VirtualFileShareThe stream share mode.
provider
IVirtualFileProviderThe provider used to load the stream.
Returns
- Stream
The stream.
OpenStreamAsync(string, VirtualFileMode, VirtualFileAccess, VirtualFileShare)
public static Task<Stream> OpenStreamAsync(string path, VirtualFileMode mode, VirtualFileAccess access, VirtualFileShare share = VirtualFileShare.Read)
Parameters
path
stringmode
VirtualFileModeaccess
VirtualFileAccessshare
VirtualFileShare
Returns
RegisterProvider(IVirtualFileProvider)
Registers the specified virtual file provider at the specified mount location.
public static void RegisterProvider(IVirtualFileProvider provider)
Parameters
provider
IVirtualFileProviderThe provider.
RemountFileSystem(string, string)
Mounts or remounts the specified path in the specified virtual file mount point.
public static IVirtualFileProvider RemountFileSystem(string mountPoint, string path)
Parameters
Returns
ResolveAbsolutePath(string)
Returns the path with its .. or . parts simplified.
public static string ResolveAbsolutePath(string path)
Parameters
path
stringThe path.
Returns
- string
The resolved absolute path.
ResolvePath(string)
Resolves the path.
public static string ResolvePath(string path)
Parameters
path
stringThe path.
Returns
- string
The resolved path.
ResolveProvider(string, bool)
Resolves the virtual file provider for a given path.
public static VirtualFileSystem.ResolveProviderResult ResolveProvider(string path, bool resolveTop)
Parameters
Returns
- VirtualFileSystem.ResolveProviderResult
The virtual file system provider and local path in it.
Exceptions
- InvalidOperationException
path cannot be resolved to a provider.
ResolveProviderUnsafe(string, bool)
public static VirtualFileSystem.ResolveProviderResult ResolveProviderUnsafe(string path, bool resolveTop)
Parameters
Returns
UnregisterProvider(IVirtualFileProvider, bool)
Unregisters the specified virtual file provider.
public static void UnregisterProvider(IVirtualFileProvider provider, bool dispose = true)
Parameters
provider
IVirtualFileProviderThe provider.
dispose
boolIndicate that the provider should be disposed, if it inherits from IDisposable interface.