Class VirtualFileSystem
Virtual abstraction over a file system. It handles access to files, http, packages, path rewrite, etc...
public static class VirtualFileSystem- Inheritance
- 
      objectVirtualFileSystem
Fields
AllDirectorySeparatorChars
public static readonly char[] AllDirectorySeparatorCharsField Value
- char[]
AltDirectorySeparatorChar
public static readonly char AltDirectorySeparatorCharField Value
ApplicationBinary
The application binary folder.
public static readonly IVirtualFileProvider ApplicationBinaryField Value
ApplicationCache
The application cache folder.
public static readonly IVirtualFileProvider ApplicationCacheField Value
ApplicationData
The application data file provider.
public static readonly IVirtualFileProvider ApplicationDataField Value
ApplicationDatabase
The application database file provider (Index level).
public static readonly IVirtualFileProvider ApplicationDatabaseField Value
ApplicationDatabaseIndexName
public static readonly string ApplicationDatabaseIndexNameField Value
ApplicationDatabaseIndexPath
public static readonly string ApplicationDatabaseIndexPathField Value
ApplicationDatabasePath
public static readonly string ApplicationDatabasePathField Value
ApplicationLocal
The application user local folder. Included in backup.
public static readonly IVirtualFileProvider ApplicationLocalField Value
ApplicationObjectDatabase
The application database file provider (ObjectId level).
public static IVirtualFileProvider ApplicationObjectDatabaseField Value
ApplicationRoaming
The application user roaming folder. Included in backup.
public static readonly IVirtualFileProvider ApplicationRoamingField Value
ApplicationTemporary
The application temporary data provider.
public static readonly IVirtualFileProvider ApplicationTemporaryField Value
DirectorySeparatorChar
public static readonly char DirectorySeparatorCharField Value
Drive
The whole host file system. This should be used only in tools.
public static readonly DriveFileProvider DriveField Value
LocalDatabasePath
public static readonly string LocalDatabasePathField 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
- pathstring
- The 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
- pathstring
- The path of the directory to check. 
Returns
- bool
- True if the directory exists, false otherwise. 
FileDelete(string)
public static void FileDelete(string path)Parameters
- pathstring
FileExists(string)
Checks the existence of a file.
public static bool FileExists(string path)Parameters
- pathstring
- The 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
- pathstring
Returns
FileMove(string, string)
public static void FileMove(string sourcePath, string destinationPath)Parameters
FileSize(string)
public static long FileSize(string path)Parameters
- pathstring
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
- pathstring
- The 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
- pathstring
- path 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
- pathstring
Returns
GetParentFolder(string)
Gets the parent folder.
public static string GetParentFolder(string path)Parameters
- pathstring
- The 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
- pathstring
- The path. 
- searchPatternstring
- The search pattern. 
- searchOptionVirtualSearchOption
- The 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
- pathstring
- The path. 
- modeVirtualFileMode
- The stream opening mode (append, open, create, etc...). 
- accessVirtualFileAccess
- The stream access. 
- shareVirtualFileShare
- The 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
- pathstring
- The path. 
- modeVirtualFileMode
- The stream opening mode (append, open, create, etc...). 
- accessVirtualFileAccess
- The stream access. 
- shareVirtualFileShare
- The stream share mode. 
- providerIVirtualFileProvider
- The 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
- pathstring
- modeVirtualFileMode
- accessVirtualFileAccess
- shareVirtualFileShare
Returns
RegisterProvider(IVirtualFileProvider)
Registers the specified virtual file provider at the specified mount location.
public static void RegisterProvider(IVirtualFileProvider provider)Parameters
- providerIVirtualFileProvider
- The 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
- pathstring
- The path. 
Returns
- string
- The resolved absolute path. 
ResolvePath(string)
Resolves the path.
public static string ResolvePath(string path)Parameters
- pathstring
- The 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
- providerIVirtualFileProvider
- The provider. 
- disposebool
- Indicate that the provider should be disposed, if it inherits from IDisposable interface.