Interface IFileSystem
Provides methods allowing the manipulation of files.
Namespace: Umbraco.Cms.Core.IO
Assembly: Umbraco.Core.dll
Syntax
public interface IFileSystem
Properties
View SourceCanAddPhysical
Gets a value indicating whether the filesystem can add/copy a file which is on a physical filesystem.
Declaration
bool CanAddPhysical { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
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 SourceAddFile(String, Stream)
Adds a file to the file system.
Declaration
void AddFile(string path, Stream stream)
Parameters
Type | Name | Description |
---|---|---|
System.String | path | The path to the given file. |
Stream | stream | The |
AddFile(String, Stream, Boolean)
Adds a file to the file system.
Declaration
void AddFile(string path, Stream stream, bool overrideIfExists)
Parameters
Type | Name | Description |
---|---|---|
System.String | path | The path to the given file. |
Stream | stream | The |
System.Boolean | overrideIfExists | Whether to override the file if it already exists. |
AddFile(String, String, Boolean, Boolean)
Adds a file which is on a physical filesystem.
Declaration
void AddFile(string path, string physicalPath, bool overrideIfExists = true, bool copy = false)
Parameters
Type | Name | Description |
---|---|---|
System.String | path | The path to the file. |
System.String | physicalPath | The absolute physical path to the source file. |
System.Boolean | overrideIfExists | A value indicating what to do if the file already exists. |
System.Boolean | copy | A value indicating whether to move (default) or copy. |
DeleteDirectory(String)
Deletes the specified directory.
Declaration
void DeleteDirectory(string path)
Parameters
Type | Name | Description |
---|---|---|
System.String | path | The name of the directory to remove. |
DeleteDirectory(String, Boolean)
Deletes the specified directory and, if indicated, any subdirectories and files in the directory.
Declaration
void DeleteDirectory(string path, bool recursive)
Parameters
Type | Name | Description |
---|---|---|
System.String | path | The name of the directory to remove. |
System.Boolean | recursive | Whether to remove directories, subdirectories, and files in path. |
Remarks
Azure blob storage has no real concept of directories so deletion is always recursive.
DeleteFile(String)
Deletes the specified file.
Declaration
void DeleteFile(string path)
Parameters
Type | Name | Description |
---|---|---|
System.String | path | The name of the file to remove. |
DirectoryExists(String)
Determines whether the specified directory exists.
Declaration
bool DirectoryExists(string path)
Parameters
Type | Name | Description |
---|---|---|
System.String | path | The directory to check. |
Returns
Type | Description |
---|---|
System.Boolean |
|
FileExists(String)
Determines whether the specified file exists.
Declaration
bool FileExists(string path)
Parameters
Type | Name | Description |
---|---|---|
System.String | path | The file to check. |
Returns
Type | Description |
---|---|
System.Boolean |
|
GetCreated(String)
Gets the created date/time of the file, expressed as a UTC value.
Declaration
DateTimeOffset GetCreated(string path)
Parameters
Type | Name | Description |
---|---|---|
System.String | path | The path to the file. |
Returns
Type | Description |
---|---|
DateTimeOffset |
GetDirectories(String)
Gets all directories matching the given path.
Declaration
IEnumerable<string> GetDirectories(string path)
Parameters
Type | Name | Description |
---|---|---|
System.String | path | The path to the directories. |
Returns
Type | Description |
---|---|
IEnumerable<System.String> | The |
GetFiles(String)
Gets all files matching the given path.
Declaration
IEnumerable<string> GetFiles(string path)
Parameters
Type | Name | Description |
---|---|---|
System.String | path | The path to the files. |
Returns
Type | Description |
---|---|
IEnumerable<System.String> | The |
GetFiles(String, String)
Gets all files matching the given path and filter.
Declaration
IEnumerable<string> GetFiles(string path, string filter)
Parameters
Type | Name | Description |
---|---|---|
System.String | path | The path to the files. |
System.String | filter | A filter that allows the querying of file extension.
|
Returns
Type | Description |
---|---|
IEnumerable<System.String> | The |
GetFullPath(String)
Gets the full qualified path to the file.
Declaration
string GetFullPath(string path)
Parameters
Type | Name | Description |
---|---|---|
System.String | path | The file to return the full path for. |
Returns
Type | Description |
---|---|
System.String | The System.String representing the full path. |
GetLastModified(String)
Gets the last modified date/time of the file, expressed as a UTC value.
Declaration
DateTimeOffset GetLastModified(string path)
Parameters
Type | Name | Description |
---|---|---|
System.String | path | The path to the file. |
Returns
Type | Description |
---|---|
DateTimeOffset |
GetRelativePath(String)
Returns the application relative path to the file.
Declaration
string GetRelativePath(string fullPathOrUrl)
Parameters
Type | Name | Description |
---|---|---|
System.String | fullPathOrUrl | The full path or URL. |
Returns
Type | Description |
---|---|
System.String | The System.String representing the relative path. |
GetSize(String)
Gets the size of a file.
Declaration
long GetSize(string path)
Parameters
Type | Name | Description |
---|---|---|
System.String | path | The path to the file. |
Returns
Type | Description |
---|---|
System.Int64 | The size (in bytes) of the file. |
GetUrl(String)
Returns the application relative URL to the file.
Declaration
string GetUrl(string path)
Parameters
Type | Name | Description |
---|---|---|
System.String | path | The path to return the URL for. |
Returns
Type | Description |
---|---|
System.String | System.String representing the relative URL. |
OpenFile(String)
Gets a
Declaration
Stream OpenFile(string path)
Parameters
Type | Name | Description |
---|---|---|
System.String | path | The path to the file. |
Returns
Type | Description |
---|---|
Stream |