Class DirectoryHelper
Directory management methods.
public class DirectoryHelper : AbstractHelper<DirectoryHelper>
- Inheritance
-
objectDirectoryHelper
- Inherited Members
- Extension Methods
Constructors
DirectoryHelper()
public DirectoryHelper()
Properties
AllowCheckIOPermissions
Allow checking IO permissions?
public static bool AllowCheckIOPermissions { get; }
Property Value
- bool
IsWebRootWritable
Returns whether web root is writable.
public static bool IsWebRootWritable { get; }
Property Value
- bool
Methods
CheckPermissions(CheckPermissionsSettings)
Check write permissions.
public static bool CheckPermissions(CheckPermissionsSettings permissionsSettings)
Parameters
permissionsSettingsCheckPermissionsSettings
Returns
- bool
Remarks
Permissions are checked only on Windows platform. The check passes by default on other platforms.
CheckPermissions(string)
Check permissions (checks read and write permissions).
public static bool CheckPermissions(string path)
Parameters
pathstringDirectory path
Returns
- bool
Remarks
Permissions are checked only on Windows platform. The check passes by default on other platforms.
CheckPermissions(string, bool, bool, bool, bool)
Check write permissions.
public static bool CheckPermissions(string path, bool checkRead, bool checkWrite, bool checkModify, bool checkDelete)
Parameters
pathstringDirectory path
checkReadboolIf read permissions should be checked
checkWriteboolIf write permissions should be checked
checkModifyboolIf modify permissions should be checked
checkDeleteboolIf delete permissions should be checked
Returns
- bool
Remarks
Permissions are checked only on Windows platform. The check passes by default on other platforms.
CheckPermissionsInternal(CheckPermissionsSettings)
Check write permissions.
protected virtual bool CheckPermissionsInternal(CheckPermissionsSettings permissionsSettings)
Parameters
permissionsSettingsCheckPermissionsSettings
Returns
- bool
Remarks
Permissions are checked only on Windows platform. The check passes by default on other platforms.
CheckPermissionsInternal(string, bool, bool, bool, bool)
Check write permissions.
protected virtual bool CheckPermissionsInternal(string path, bool checkRead, bool checkWrite, bool checkModify, bool checkDelete)
Parameters
pathstringDirectory path
checkReadboolIf read permissions should be checked
checkWriteboolIf write permissions should be checked
checkModifyboolIf modify permissions should be checked
checkDeleteboolIf delete permissions should be checked
Returns
- bool
Remarks
Permissions are checked only on Windows platform. The check passes by default on other platforms.
CombinePath(params string[])
Combines parts of one path together, handles slashes. Path ends without DirectorySeparatorChar.
public static string CombinePath(params string[] paths)
Parameters
pathsstring[]Parts to combine
Returns
- string
CombinePathInternal(params string[])
Combines parts of one path together, handles back slashes.
protected virtual string CombinePathInternal(params string[] paths)
Parameters
pathsstring[]Parts to combine
Returns
- string
CopyDirectoryInternal(string, string)
Copies specified directory including its subdirectories and all underlying files.
protected virtual void CopyDirectoryInternal(string sourcePath, string targetPath)
Parameters
sourcePathstringFull disk path of the source directory
targetPathstringFull disk path of the new copy of the directory including its name
CopyFile(string, string)
Copies the file.
public static void CopyFile(string sourcePath, string targetPath)
Parameters
sourcePathstringSource path
targetPathstringTarget directory
CopyFileInternal(string, string)
Copies the file.
protected virtual void CopyFileInternal(string sourcePath, string targetPath)
Parameters
sourcePathstringSource path
targetPathstringTarget directory
CreateDirectory(string)
Creates directory. It works also in a shared hosting environment.
public static DirectoryInfo CreateDirectory(string path)
Parameters
pathstringFull disk path of the new directory
Returns
- DirectoryInfo
Returns DirectoryInfo representing the new directory.
CreateDirectoryInternal(string)
Creates directory. It works also in a shared hosting environment.
protected virtual DirectoryInfo CreateDirectoryInternal(string path)
Parameters
pathstringFull disk path of the new directory
Returns
- DirectoryInfo
Returns DirectoryInfo representing the new directory.
DeleteDirectory(string)
Deletes the directory. It works also in a shared hosting environment.
public static void DeleteDirectory(string path)
Parameters
pathstringFull disk path of the directory to delete
DeleteDirectory(string, bool)
Deletes the directory. It works also in a shared hosting environment.
public static void DeleteDirectory(string path, bool recursive)
Parameters
pathstringFull disk path of the directory to delete
recursiveboolIf true, the directory is deleted recursively
DeleteDirectoryInternal(string)
Deletes the directory. It works also in a shared hosting environment.
protected virtual void DeleteDirectoryInternal(string path)
Parameters
pathstringFull disk path of the directory to delete
DeleteDirectoryInternal(string, bool)
Deletes the directory. It works also in a shared hosting environment.
protected virtual void DeleteDirectoryInternal(string path, bool recursive)
Parameters
pathstringFull disk path of the directory to delete
recursiveboolIf true, the directory is deleted recursively
DeleteDirectoryStructure(string)
Deletes the directory structure. It works also in a shared hosting environment.
public static void DeleteDirectoryStructure(string path)
Parameters
pathstringFull disk path of the directory to delete
DeleteDirectoryStructureInternal(string)
Deletes the directory structure. It works also in a shared hosting environment.
protected virtual void DeleteDirectoryStructureInternal(string path)
Parameters
pathstringFull disk path of the directory to delete
EnsureDiskPath(string, string)
Checks if all folders of the given path exist and if not, it creates them.
public static void EnsureDiskPath(string path, string startingPath)
Parameters
pathstringFull disk path of the file including file name
startingPathstringStarting path (subset of file path) that will not be checked
EnsureDiskPathInternal(string, string)
Checks if all folders of the given path exist and if not, it creates them.
protected virtual void EnsureDiskPathInternal(string path, string startingPath)
Parameters
pathstringFull disk path of the file including file name
startingPathstringStarting path (subset of file path) that will not be checked
EnsurePathSlashInternal(string)
This method ensures that path will end with one DirectorySeparatorChar.
protected virtual string EnsurePathSlashInternal(string path)
Parameters
pathstringPath to ensure
Returns
- string