Table of Contents

Class VirtualFileSystem

Namespace
Stride.Core.IO
Assembly
Stride.Core.IO.dll

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

char

ApplicationBinary

The application binary folder.

public static readonly IVirtualFileProvider ApplicationBinary

Field Value

IVirtualFileProvider

ApplicationCache

The application cache folder.

public static readonly IVirtualFileProvider ApplicationCache

Field Value

IVirtualFileProvider

ApplicationData

The application data file provider.

public static readonly IVirtualFileProvider ApplicationData

Field Value

IVirtualFileProvider

ApplicationDatabase

The application database file provider (Index level).

public static readonly IVirtualFileProvider ApplicationDatabase

Field Value

IVirtualFileProvider

ApplicationDatabaseIndexName

public static readonly string ApplicationDatabaseIndexName

Field Value

string

ApplicationDatabaseIndexPath

public static readonly string ApplicationDatabaseIndexPath

Field Value

string

ApplicationDatabasePath

public static readonly string ApplicationDatabasePath

Field Value

string

ApplicationLocal

The application user local folder. Included in backup.

public static readonly IVirtualFileProvider ApplicationLocal

Field Value

IVirtualFileProvider

ApplicationObjectDatabase

The application database file provider (ObjectId level).

public static IVirtualFileProvider ApplicationObjectDatabase

Field Value

IVirtualFileProvider

ApplicationRoaming

The application user roaming folder. Included in backup.

public static readonly IVirtualFileProvider ApplicationRoaming

Field Value

IVirtualFileProvider

ApplicationTemporary

The application temporary data provider.

public static readonly IVirtualFileProvider ApplicationTemporary

Field Value

IVirtualFileProvider

DirectorySeparatorChar

public static readonly char DirectorySeparatorChar

Field Value

char

Drive

The whole host file system. This should be used only in tools.

public static readonly DriveFileProvider Drive

Field Value

DriveFileProvider

LocalDatabasePath

public static readonly string LocalDatabasePath

Field Value

string

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

path string
relativePath string

Returns

string

Combine(string, string)

Combines the specified paths. Similiar to Combine(string, string).

public static string Combine(string path1, string path2)

Parameters

path1 string

The path1.

path2 string

The path2.

Returns

string

The combined path.

CreateDirectory(string)

Creates all directories so that path exists.

public static void CreateDirectory(string path)

Parameters

path string

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

target string

The target.

sourcePath string

The source path.

Returns

string

The relative path.

DirectoryExists(string)

Checks the existence of a directory.

public static bool DirectoryExists(string path)

Parameters

path string

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

path string

FileExists(string)

Checks the existence of a file.

public static bool FileExists(string path)

Parameters

path string

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

path string

Returns

Task<bool>

FileMove(string, string)

public static void FileMove(string sourcePath, string destinationPath)

Parameters

sourcePath string
destinationPath string

FileSize(string)

public static long FileSize(string path)

Parameters

path string

Returns

long

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 string

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

path string

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

path string

Returns

DateTime

GetParentFolder(string)

Gets the parent folder.

public static string GetParentFolder(string path)

Parameters

path string

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

path string

The path.

searchPattern string

The search pattern.

searchOption VirtualSearchOption

The search option.

Returns

Task<string[]>

The list of files matching the pattern.

MountFileSystem(string, string)

Mounts the specified path in the specified virtual file mount point.

public static IVirtualFileProvider MountFileSystem(string mountPoint, string path)

Parameters

mountPoint string

The mount point in the VFS.

path string

The directory path.

Returns

IVirtualFileProvider

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 string

The path.

mode VirtualFileMode

The stream opening mode (append, open, create, etc...).

access VirtualFileAccess

The stream access.

share VirtualFileShare

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

path string

The path.

mode VirtualFileMode

The stream opening mode (append, open, create, etc...).

access VirtualFileAccess

The stream access.

share VirtualFileShare

The stream share mode.

provider IVirtualFileProvider

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

path string
mode VirtualFileMode
access VirtualFileAccess
share VirtualFileShare

Returns

Task<Stream>

RegisterProvider(IVirtualFileProvider)

Registers the specified virtual file provider at the specified mount location.

public static void RegisterProvider(IVirtualFileProvider provider)

Parameters

provider IVirtualFileProvider

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

mountPoint string

The mount point in the VFS.

path string

The directory path.

Returns

IVirtualFileProvider

ResolveAbsolutePath(string)

Returns the path with its .. or . parts simplified.

public static string ResolveAbsolutePath(string path)

Parameters

path string

The path.

Returns

string

The resolved absolute path.

ResolvePath(string)

Resolves the path.

public static string ResolvePath(string path)

Parameters

path string

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

path string

The path.

resolveTop bool

if set to true [resolve top].

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

path string
resolveTop bool

Returns

VirtualFileSystem.ResolveProviderResult

UnregisterProvider(IVirtualFileProvider, bool)

Unregisters the specified virtual file provider.

public static void UnregisterProvider(IVirtualFileProvider provider, bool dispose = true)

Parameters

provider IVirtualFileProvider

The provider.

dispose bool

Indicate that the provider should be disposed, if it inherits from IDisposable interface.