Stride

OPEN / CLOSE
  • Features
  • Blog
  • Documentation
  • Community
(icon) Download

  • Discord
  • Facebook
  • Twitter
  • YouTube

LANGUAGE

OPEN / CLOSE
  • English
  • 日本語
    Show / Hide Table of Contents

    VirtualFileSystem Class

    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...

    System.Object → VirtualFileSystem
    Derived from VirtualFileSystem:

    public static class VirtualFileSystem
    Name Description
    Fields
    AllDirectorySeparatorChars
    AltDirectorySeparatorChar
    ApplicationBinary

    The application binary folder.

    ApplicationCache

    The application cache folder.

    ApplicationData

    The application data file provider.

    ApplicationDatabase

    The application database file provider (Index level).

    ApplicationDatabaseIndexName
    ApplicationDatabaseIndexPath
    ApplicationDatabasePath
    ApplicationLocal

    The application user local folder. Included in backup.

    ApplicationObjectDatabase

    The application database file provider (ObjectId level).

    ApplicationRoaming

    The application user roaming folder. Included in backup.

    ApplicationTemporary

    The application temporary data provider.

    DirectorySeparatorChar
    Drive

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

    LocalDatabasePath
    Properties
    Providers

    Gets the registered providers.

    Methods
    BuildPath(String, String)
    Combine(String, String)

    Combines the specified paths. Similiar to System.IO.Path.Combine(System.String,System.String).

    CreateDirectory(String)

    Creates all directories so that path exists.

    CreateRelativePath(String, String)

    Creates the relative path that can access to from .

    DirectoryExists(String)

    Checks the existence of a directory.

    FileDelete(String)
    FileExists(String)

    Checks the existence of a file.

    FileExistsAsync(String)
    FileMove(String, String)
    FileSize(String)
    GetAbsolutePath(String)

    Gets the absolute path (system dependent) for the specified path in the context of the virtual file system.

    GetFileName(String)

    Gets the file's name with its extension ("/path/to/file/fileName.ext"->"fileName.ext")

    GetLastWriteTime(String)
    GetParentFolder(String)

    Gets the parent folder.

    GetTempFileName()

    Creates a temporary zero-byte file and returns its full path.

    ListFiles(String, String, VirtualSearchOption)

    Lists the files matching a pattern in a specified directory.

    MountFileSystem(String, String)

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

    OpenStream(String, VirtualFileMode, VirtualFileAccess, VirtualFileShare)

    Opens the stream from a given path.

    OpenStream(String, VirtualFileMode, VirtualFileAccess, VirtualFileShare, out IVirtualFileProvider)

    Opens the stream from a given path.

    OpenStreamAsync(String, VirtualFileMode, VirtualFileAccess, VirtualFileShare)
    RegisterProvider(IVirtualFileProvider)

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

    RemountFileSystem(String, String)

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

    ResolveAbsolutePath(String)

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

    ResolvePath(String)

    Resolves the path.

    ResolveProvider(String, Boolean)

    Resolves the virtual file provider for a given path.

    ResolveProviderUnsafe(String, Boolean)
    UnregisterProvider(IVirtualFileProvider, Boolean)

    Unregisters the specified virtual file provider.

    | Improve this Doc View Source

    Fields


    AllDirectorySeparatorChars

    public static readonly char[] AllDirectorySeparatorChars
    Field Value
    Type Description
    System.Char[]

    AltDirectorySeparatorChar

    public static readonly char AltDirectorySeparatorChar
    Field Value
    Type Description
    System.Char

    ApplicationBinary

    The application binary folder.

    public static readonly IVirtualFileProvider ApplicationBinary
    Field Value
    Type Description
    IVirtualFileProvider

    ApplicationCache

    The application cache folder.

    public static readonly IVirtualFileProvider ApplicationCache
    Field Value
    Type Description
    IVirtualFileProvider

    ApplicationData

    The application data file provider.

    public static readonly IVirtualFileProvider ApplicationData
    Field Value
    Type Description
    IVirtualFileProvider

    ApplicationDatabase

    The application database file provider (Index level).

    public static readonly IVirtualFileProvider ApplicationDatabase
    Field Value
    Type Description
    IVirtualFileProvider

    ApplicationDatabaseIndexName

    public static readonly string ApplicationDatabaseIndexName
    Field Value
    Type Description
    System.String

    ApplicationDatabaseIndexPath

    public static readonly string ApplicationDatabaseIndexPath
    Field Value
    Type Description
    System.String

    ApplicationDatabasePath

    public static readonly string ApplicationDatabasePath
    Field Value
    Type Description
    System.String

    ApplicationLocal

    The application user local folder. Included in backup.

    public static readonly IVirtualFileProvider ApplicationLocal
    Field Value
    Type Description
    IVirtualFileProvider

    ApplicationObjectDatabase

    The application database file provider (ObjectId level).

    public static IVirtualFileProvider ApplicationObjectDatabase
    Field Value
    Type Description
    IVirtualFileProvider

    ApplicationRoaming

    The application user roaming folder. Included in backup.

    public static readonly IVirtualFileProvider ApplicationRoaming
    Field Value
    Type Description
    IVirtualFileProvider

    ApplicationTemporary

    The application temporary data provider.

    public static readonly IVirtualFileProvider ApplicationTemporary
    Field Value
    Type Description
    IVirtualFileProvider

    DirectorySeparatorChar

    public static readonly char DirectorySeparatorChar
    Field Value
    Type Description
    System.Char

    Drive

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

    public static readonly DriveFileProvider Drive
    Field Value
    Type Description
    DriveFileProvider

    LocalDatabasePath

    public static readonly string LocalDatabasePath
    Field Value
    Type Description
    System.String
    | Improve this Doc View Source

    Properties


    Providers

    Gets the registered providers.

    public static IEnumerable<IVirtualFileProvider> Providers { get; }
    Property Value
    Type Description
    System.Collections.Generic.IEnumerable<IVirtualFileProvider>

    The providers.

    | Improve this Doc View Source

    Methods


    BuildPath(String, String)

    public static string BuildPath(string path, string relativePath)
    Parameters
    Type Name Description
    System.String path
    System.String relativePath
    Returns
    Type Description
    System.String

    Combine(String, String)

    Combines the specified paths. Similiar to System.IO.Path.Combine(System.String,System.String).

    public static string Combine(string path1, string path2)
    Parameters
    Type Name Description
    System.String path1

    The path1.

    System.String path2

    The path2.

    Returns
    Type Description
    System.String

    The combined path.


    CreateDirectory(String)

    Creates all directories so that path exists.

    public static void CreateDirectory(string path)
    Parameters
    Type Name Description
    System.String path

    The path.


    CreateRelativePath(String, String)

    Creates the relative path that can access to from .

    public static string CreateRelativePath(string target, string sourcePath)
    Parameters
    Type Name Description
    System.String target

    The target.

    System.String sourcePath

    The source path.

    Returns
    Type Description
    System.String

    The relative path.


    DirectoryExists(String)

    Checks the existence of a directory.

    public static bool DirectoryExists(string path)
    Parameters
    Type Name Description
    System.String path

    The path of the directory to check.

    Returns
    Type Description
    System.Boolean

    True if the directory exists, false otherwise.


    FileDelete(String)

    public static void FileDelete(string path)
    Parameters
    Type Name Description
    System.String path

    FileExists(String)

    Checks the existence of a file.

    public static bool FileExists(string path)
    Parameters
    Type Name Description
    System.String path

    The path of the file to check.

    Returns
    Type Description
    System.Boolean

    True if the file exists, false otherwise.


    FileExistsAsync(String)

    public static Task<bool> FileExistsAsync(string path)
    Parameters
    Type Name Description
    System.String path
    Returns
    Type Description
    System.Threading.Tasks.Task<System.Boolean>

    FileMove(String, String)

    public static void FileMove(string sourcePath, string destinationPath)
    Parameters
    Type Name Description
    System.String sourcePath
    System.String destinationPath

    FileSize(String)

    public static long FileSize(string path)
    Parameters
    Type Name Description
    System.String path
    Returns
    Type Description
    System.Int64

    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
    Type Name Description
    System.String path

    The path local to the virtual file system.

    Returns
    Type Description
    System.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
    Type Name Description
    System.String path

    path containing file's path and name

    Returns
    Type Description
    System.String

    The name of the file with its extension


    GetLastWriteTime(String)

    public static DateTime GetLastWriteTime(string path)
    Parameters
    Type Name Description
    System.String path
    Returns
    Type Description
    System.DateTime

    GetParentFolder(String)

    Gets the parent folder.

    public static string GetParentFolder(string path)
    Parameters
    Type Name Description
    System.String path

    The path.

    Returns
    Type Description
    System.String

    The parent folder.

    Exceptions
    Type Condition
    System.ArgumentNullException

    path

    System.ArgumentException

    path doesn't contain a /;path


    GetTempFileName()

    Creates a temporary zero-byte file and returns its full path.

    public static string GetTempFileName()
    Returns
    Type Description
    System.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
    Type Name Description
    System.String path

    The path.

    System.String searchPattern

    The search pattern.

    VirtualSearchOption searchOption

    The search option.

    Returns
    Type Description
    System.Threading.Tasks.Task<System.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
    Type Name Description
    System.String mountPoint

    The mount point in the VFS.

    System.String path

    The directory path.

    Returns
    Type Description
    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
    Type Name Description
    System.String path

    The path.

    VirtualFileMode mode

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

    VirtualFileAccess access

    The stream access.

    VirtualFileShare share

    The stream share mode.

    Returns
    Type Description
    System.IO.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
    Type Name Description
    System.String path

    The path.

    VirtualFileMode mode

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

    VirtualFileAccess access

    The stream access.

    VirtualFileShare share

    The stream share mode.

    IVirtualFileProvider provider

    The provider used to load the stream.

    Returns
    Type Description
    System.IO.Stream

    The stream.


    OpenStreamAsync(String, VirtualFileMode, VirtualFileAccess, VirtualFileShare)

    public static Task<Stream> OpenStreamAsync(string path, VirtualFileMode mode, VirtualFileAccess access, VirtualFileShare share = VirtualFileShare.Read)
    Parameters
    Type Name Description
    System.String path
    VirtualFileMode mode
    VirtualFileAccess access
    VirtualFileShare share
    Returns
    Type Description
    System.Threading.Tasks.Task<System.IO.Stream>

    RegisterProvider(IVirtualFileProvider)

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

    public static void RegisterProvider(IVirtualFileProvider provider)
    Parameters
    Type Name Description
    IVirtualFileProvider provider

    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
    Type Name Description
    System.String mountPoint

    The mount point in the VFS.

    System.String path

    The directory path.

    Returns
    Type Description
    IVirtualFileProvider

    ResolveAbsolutePath(String)

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

    public static string ResolveAbsolutePath(string path)
    Parameters
    Type Name Description
    System.String path

    The path.

    Returns
    Type Description
    System.String

    The resolved absolute path.


    ResolvePath(String)

    Resolves the path.

    public static string ResolvePath(string path)
    Parameters
    Type Name Description
    System.String path

    The path.

    Returns
    Type Description
    System.String

    The resolved path.


    ResolveProvider(String, Boolean)

    Resolves the virtual file provider for a given path.

    public static VirtualFileSystem.ResolveProviderResult ResolveProvider(string path, bool resolveTop)
    Parameters
    Type Name Description
    System.String path

    The path.

    System.Boolean resolveTop

    if set to true [resolve top].

    Returns
    Type Description
    VirtualFileSystem.ResolveProviderResult

    The virtual file system provider and local path in it.

    Exceptions
    Type Condition
    System.InvalidOperationException

    path cannot be resolved to a provider.


    ResolveProviderUnsafe(String, Boolean)

    public static VirtualFileSystem.ResolveProviderResult ResolveProviderUnsafe(string path, bool resolveTop)
    Parameters
    Type Name Description
    System.String path
    System.Boolean resolveTop
    Returns
    Type Description
    VirtualFileSystem.ResolveProviderResult

    UnregisterProvider(IVirtualFileProvider, Boolean)

    Unregisters the specified virtual file provider.

    public static void UnregisterProvider(IVirtualFileProvider provider, bool dispose = true)
    Parameters
    Type Name Description
    IVirtualFileProvider provider

    The provider.

    System.Boolean dispose

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


    • Improve this Doc
    • View Source
    In This Article

    Back to top

    Copyright © 2019-2021 .NET Foundation and Contributors
    Supported by the .NET Foundation