Class IOHelper
Provides base implementation for IO helper operations.
Inheritance
Namespace: Umbraco.Cms.Core.IO
Assembly: Umbraco.Core.dll
Syntax
public abstract class IOHelper : IIOHelper
Constructors
View SourceIOHelper(IHostingEnvironment)
Initializes a new instance of the IOHelper class.
Declaration
public IOHelper(IHostingEnvironment hostingEnvironment)
Parameters
| Type | Name | Description |
|---|---|---|
| IHostingEnvironment | hostingEnvironment | The hosting environment. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown when |
Methods
View SourceCleanFolder(DirectoryInfo, TimeSpan)
Cleans contents of a folder by deleting all files older that the provided age. If deletition of any file errors (e.g. due to a file lock) the process will continue to try to delete all that it can.
Declaration
public CleanFolderResult CleanFolder(DirectoryInfo folder, TimeSpan age)
Parameters
| Type | Name | Description |
|---|---|---|
| DirectoryInfo | folder | Folder to clean. |
| TimeSpan | age | Age of files within folder to delete. |
Returns
| Type | Description |
|---|---|
| CleanFolderResult | Result of operation. |
EnsurePathExists(string)
Ensures that the specified path exists by creating it if necessary.
Declaration
public void EnsurePathExists(string path)
Parameters
| Type | Name | Description |
|---|---|---|
| string | path | The path to ensure exists. |
FindFile(string)
Finds a file by its virtual path and returns the resolved path.
Declaration
public string FindFile(string virtualPath)
Parameters
| Type | Name | Description |
|---|---|---|
| string | virtualPath | The virtual path to find. |
Returns
| Type | Description |
|---|---|
| string | The resolved file path. |
GetRelativePath(string)
Get properly formatted relative path from an existing absolute or relative path
Declaration
public string GetRelativePath(string path)
Parameters
| Type | Name | Description |
|---|---|---|
| string | path |
Returns
| Type | Description |
|---|---|
| string |
GetTempFolders()
Retrieves array of temporary folders from the hosting environment.
Declaration
public DirectoryInfo[] GetTempFolders()
Returns
| Type | Description |
|---|---|
| DirectoryInfo[] | Array of System.IO.DirectoryInfo instances. |
MapPath(string)
Maps a virtual path to a physical path in the content root folder (i.e. www)
Declaration
public string MapPath(string path)
Parameters
| Type | Name | Description |
|---|---|---|
| string | path |
Returns
| Type | Description |
|---|---|
| string |
PathStartsWith(string, string, params char[])
Determines whether a path starts with the specified root path.
Declaration
public abstract bool PathStartsWith(string path, string root, params char[] separators)
Parameters
| Type | Name | Description |
|---|---|---|
| string | path | The path to check. |
| string | root | The root path to compare against. |
| char[] | separators | The directory separator characters to use. |
Returns
| Type | Description |
|---|---|
| bool |
|
ResolveUrl(string)
Resolves a virtual path to an absolute URL.
Declaration
public string ResolveUrl(string virtualPath)
Parameters
| Type | Name | Description |
|---|---|---|
| string | virtualPath | The virtual path to resolve. |
Returns
| Type | Description |
|---|---|
| string | The absolute URL. |
VerifyEditPath(string, IEnumerable<string>)
Verifies that the current filepath matches one of several directories where the user is allowed to edit a file.
Declaration
public bool VerifyEditPath(string filePath, IEnumerable<string> validDirs)
Parameters
| Type | Name | Description |
|---|---|---|
| string | filePath | The filepath to validate. |
| IEnumerable<string> | validDirs | The valid directories. |
Returns
| Type | Description |
|---|---|
| bool | A value indicating whether the filepath is valid. |
VerifyEditPath(string, string)
Verifies that the current filepath matches a directory where the user is allowed to edit a file.
Declaration
public bool VerifyEditPath(string filePath, string validDir)
Parameters
| Type | Name | Description |
|---|---|---|
| string | filePath | The filepath to validate. |
| string | validDir | The valid directory. |
Returns
| Type | Description |
|---|---|
| bool | A value indicating whether the filepath is valid. |
VerifyFileExtension(string, IEnumerable<string>)
Verifies that the current filepath has one of several authorized extensions.
Declaration
public bool VerifyFileExtension(string filePath, IEnumerable<string> validFileExtensions)
Parameters
| Type | Name | Description |
|---|---|---|
| string | filePath | The filepath to validate. |
| IEnumerable<string> | validFileExtensions | The valid extensions. |
Returns
| Type | Description |
|---|---|
| bool | A value indicating whether the filepath is valid. |