Search Results for

    Show / Hide Table of Contents
    View Source

    Class PhysicalFileSystem

    Inheritance
    object
    Namespace: Umbraco.Cms.Core.IO
    Assembly: Umbraco.Core.dll
    Syntax
    public class PhysicalFileSystem : IPhysicalFileSystem, IFileSystem, IFileProviderFactory

    Constructors

    View Source

    PhysicalFileSystem(IIOHelper, IHostingEnvironment, ILogger<PhysicalFileSystem>, string, string)

    Declaration
    public PhysicalFileSystem(IIOHelper ioHelper, IHostingEnvironment hostingEnvironment, ILogger<PhysicalFileSystem> logger, string rootPath, string rootUrl)
    Parameters
    Type Name Description
    IIOHelper ioHelper
    IHostingEnvironment hostingEnvironment
    ILogger<PhysicalFileSystem> logger
    string rootPath
    string rootUrl

    Properties

    View Source

    CanAddPhysical

    Gets a value indicating whether the filesystem can add/copy a file which is on a physical filesystem.

    Declaration
    public bool CanAddPhysical { get; }
    Property Value
    Type Description
    bool
    Remarks

    In other words, whether the filesystem can copy/move a file that is on local disk, in a fast and efficient way.

    Methods

    View Source

    AddFile(string, Stream)

    Saves a file.

    Declaration
    public void AddFile(string path, Stream stream)
    Parameters
    Type Name Description
    string path

    The filesystem-relative path of the file.

    Stream stream

    A stream containing the file data.

    Remarks

    Overrides the existing file, if any.

    View Source

    AddFile(string, Stream, bool)

    Saves a file.

    Declaration
    public void AddFile(string path, Stream stream, bool overrideExisting)
    Parameters
    Type Name Description
    string path

    The filesystem-relative path of the file.

    Stream stream

    A stream containing the file data.

    bool overrideExisting

    A value indicating whether to override the existing file, if any.

    Remarks

    If a file exists and overrideExisting is false, an exception is thrown.

    View Source

    AddFile(string, string, bool, bool)

    Adds a file which is on a physical filesystem.

    Declaration
    public void AddFile(string path, string physicalPath, bool overrideIfExists = true, bool copy = false)
    Parameters
    Type Name Description
    string path

    The path to the file.

    string physicalPath

    The absolute physical path to the source file.

    bool overrideIfExists

    A value indicating what to do if the file already exists.

    bool copy

    A value indicating whether to move (default) or copy.

    View Source

    Create()

    Creates a new Microsoft.Extensions.FileProviders.IFileProvider instance.

    Declaration
    public IFileProvider Create()
    Returns
    Type Description
    IFileProvider

    The newly created Microsoft.Extensions.FileProviders.IFileProvider instance (or null if not supported).

    View Source

    DeleteDirectory(string)

    Deletes a directory.

    Declaration
    public void DeleteDirectory(string path)
    Parameters
    Type Name Description
    string path

    The filesystem-relative path of the directory.

    View Source

    DeleteDirectory(string, bool)

    Deletes a directory.

    Declaration
    public void DeleteDirectory(string path, bool recursive)
    Parameters
    Type Name Description
    string path

    The filesystem-relative path of the directory.

    bool recursive

    A value indicating whether to recursively delete sub-directories.

    View Source

    DeleteFile(string)

    Deletes a file.

    Declaration
    public void DeleteFile(string path)
    Parameters
    Type Name Description
    string path

    The filesystem-relative path to the file.

    View Source

    DirectoryExists(string)

    Gets a value indicating whether a directory exists.

    Declaration
    public bool DirectoryExists(string path)
    Parameters
    Type Name Description
    string path

    The filesystem-relative path of the directory.

    Returns
    Type Description
    bool

    A value indicating whether a directory exists.

    View Source

    EnsureDirectory(string)

    Declaration
    protected virtual void EnsureDirectory(string path)
    Parameters
    Type Name Description
    string path
    View Source

    EnsureDirectorySeparatorChar(string)

    Declaration
    protected string EnsureDirectorySeparatorChar(string path)
    Parameters
    Type Name Description
    string path
    Returns
    Type Description
    string
    View Source

    EnsureTrailingSeparator(string)

    Declaration
    protected string EnsureTrailingSeparator(string path)
    Parameters
    Type Name Description
    string path
    Returns
    Type Description
    string
    View Source

    EnsureUrlSeparatorChar(string)

    Declaration
    protected string EnsureUrlSeparatorChar(string path)
    Parameters
    Type Name Description
    string path
    Returns
    Type Description
    string
    View Source

    FileExists(string)

    Gets a value indicating whether a file exists.

    Declaration
    public bool FileExists(string path)
    Parameters
    Type Name Description
    string path

    The filesystem-relative path to the file.

    Returns
    Type Description
    bool

    A value indicating whether the file exists.

    View Source

    GetCreated(string)

    Gets the created date of a directory or file.

    Declaration
    public DateTimeOffset GetCreated(string path)
    Parameters
    Type Name Description
    string path

    The filesystem-relative path to the directory or the file.

    Returns
    Type Description
    DateTimeOffset

    The created date of the directory or the file.

    View Source

    GetDirectories(string)

    Gets directories in a directory.

    Declaration
    public IEnumerable<string> GetDirectories(string path)
    Parameters
    Type Name Description
    string path

    The filesystem-relative path to the directory.

    Returns
    Type Description
    IEnumerable<string>

    The filesystem-relative path to the directories in the directory.

    Remarks

    Filesystem-relative paths use forward-slashes as directory separators.

    View Source

    GetFiles(string)

    Gets files in a directory.

    Declaration
    public IEnumerable<string> GetFiles(string path)
    Parameters
    Type Name Description
    string path

    The filesystem-relative path of the directory.

    Returns
    Type Description
    IEnumerable<string>

    The filesystem-relative path to the files in the directory.

    Remarks

    Filesystem-relative paths use forward-slashes as directory separators.

    View Source

    GetFiles(string, string)

    Gets files in a directory.

    Declaration
    public IEnumerable<string> GetFiles(string path, string filter)
    Parameters
    Type Name Description
    string path

    The filesystem-relative path of the directory.

    string filter

    A filter.

    Returns
    Type Description
    IEnumerable<string>

    The filesystem-relative path to the matching files in the directory.

    Remarks

    Filesystem-relative paths use forward-slashes as directory separators.

    View Source

    GetFullPath(string)

    Gets the full path.

    Declaration
    public string GetFullPath(string path)
    Parameters
    Type Name Description
    string path

    The full or filesystem-relative path.

    Returns
    Type Description
    string

    The full path.

    Remarks

    On the physical filesystem, the full path is the rooted (ie non-relative), safe (ie within this filesystem's root) path. All separators are Path.DirectorySeparatorChar.

    View Source

    GetLastModified(string)

    Gets the last-modified date of a directory or file.

    Declaration
    public DateTimeOffset GetLastModified(string path)
    Parameters
    Type Name Description
    string path

    The filesystem-relative path to the directory or the file.

    Returns
    Type Description
    DateTimeOffset

    The last modified date of the directory or the file.

    View Source

    GetRelativePath(string)

    Gets the filesystem-relative path of a full path or of an URL.

    Declaration
    public string GetRelativePath(string fullPathOrUrl)
    Parameters
    Type Name Description
    string fullPathOrUrl

    The full path or URL.

    Returns
    Type Description
    string

    The path, relative to this filesystem's root.

    Remarks

    The relative path is relative to this filesystem's root, not starting with any directory separator. All separators are forward-slashes.

    View Source

    GetSize(string)

    Gets the size of a file.

    Declaration
    public long GetSize(string path)
    Parameters
    Type Name Description
    string path

    The filesystem-relative path to the file.

    Returns
    Type Description
    long

    The file of the size, in bytes.

    Remarks

    If the file does not exist, returns -1.

    View Source

    GetUrl(string?)

    Gets the URL.

    Declaration
    public string GetUrl(string? path)
    Parameters
    Type Name Description
    string path

    The filesystem-relative path.

    Returns
    Type Description
    string

    The URL.

    Remarks

    All separators are forward-slashes.

    View Source

    MoveFile(string, string, bool)

    Moves a file from the specified source path to the specified target path.

    Declaration
    public void MoveFile(string source, string target, bool overrideIfExists = true)
    Parameters
    Type Name Description
    string source

    The path of the file or directory to move.

    string target

    The destination path where the file or directory will be moved.

    bool overrideIfExists

    A value indicating what to do if the file already exists.

    View Source

    OpenFile(string)

    Opens a file.

    Declaration
    public Stream OpenFile(string path)
    Parameters
    Type Name Description
    string path

    The filesystem-relative path to the file.

    Returns
    Type Description
    Stream
    View Source

    WithRetry(Action)

    Declaration
    protected void WithRetry(Action action)
    Parameters
    Type Name Description
    Action action
    • Edit this page
    • View Source
    In this article
    Back to top Copyright © 2016-present Umbraco
    Generated by DocFX