Search Results for

    Show / Hide Table of Contents
    View Source

    Class FileSystemExtensions

    Provides extension methods for file system operations.

    Inheritance
    object
    Namespace: Umbraco.Extensions
    Assembly: Umbraco.Core.dll
    Syntax
    public static class FileSystemExtensions

    Methods

    View Source

    CopyFile(IFileSystem, string, string)

    Copies a file from one path to another within the file system.

    Declaration
    public static void CopyFile(this IFileSystem fs, string path, string newPath)
    Parameters
    Type Name Description
    IFileSystem fs

    The file system.

    string path

    The source file path.

    string newPath

    The destination file path.

    View Source

    CreateFolder(IFileSystem, string)

    Creates a folder at the specified path.

    Declaration
    public static void CreateFolder(this IFileSystem fs, string folderPath)
    Parameters
    Type Name Description
    IFileSystem fs

    The file system.

    string folderPath

    The folder path to create.

    View Source

    GetExtension(IFileSystem, string)

    Gets the file extension from a path.

    Declaration
    public static string GetExtension(this IFileSystem fs, string path)
    Parameters
    Type Name Description
    IFileSystem fs

    The file system.

    string path

    The file path.

    Returns
    Type Description
    string

    The file extension including the period.

    View Source

    GetFileName(IFileSystem, string)

    Gets the file name from a path.

    Declaration
    public static string GetFileName(this IFileSystem fs, string path)
    Parameters
    Type Name Description
    IFileSystem fs

    The file system.

    string path

    The file path.

    Returns
    Type Description
    string

    The file name including extension.

    View Source

    GetStreamHash(Stream)

    Computes the SHA1 hash of a stream.

    Declaration
    public static string GetStreamHash(this Stream fileStream)
    Parameters
    Type Name Description
    Stream fileStream

    The stream to hash.

    Returns
    Type Description
    string

    The hexadecimal string representation of the hash.

    View Source

    OpenReadWithRetry(FileInfo, int, int)

    Attempts to open the file at

    filePath
    up to
    maxRetries
    times, with a thread sleep time of
    sleepPerRetryInMilliseconds
    between retries.
    Declaration
    public static FileStream OpenReadWithRetry(this FileInfo file, int maxRetries = 5, int sleepPerRetryInMilliseconds = 50)
    Parameters
    Type Name Description
    FileInfo file
    int maxRetries
    int sleepPerRetryInMilliseconds
    Returns
    Type Description
    FileStream
    View Source

    TryCreateFileProvider(IFileSystem, out IFileProvider)

    Creates a new Microsoft.Extensions.FileProviders.IFileProvider from the file system.

    Declaration
    public static bool TryCreateFileProvider(this IFileSystem fileSystem, out IFileProvider fileProvider)
    Parameters
    Type Name Description
    IFileSystem fileSystem

    The file system.

    IFileProvider fileProvider

    When this method returns, contains an Microsoft.Extensions.FileProviders.IFileProvider created from the file system.

    Returns
    Type Description
    bool

    true if the Microsoft.Extensions.FileProviders.IFileProvider was successfully created; otherwise, false.

    • View Source
    In this article
    Back to top Copyright © 2016-present Umbraco
    Generated by DocFX