Class Directory
Envelope for Directory classes
public static class Directory
- Inheritance
-
objectDirectory
Methods
CreateDirectory(string)
Creates all directories and subdirectories as specified by path.
public static DirectoryInfo CreateDirectory(string path)
Parameters
pathstringPath to create
Returns
Delete(string)
Deletes an empty directory.
public static void Delete(string path)
Parameters
pathstringPath to directory
Delete(string, bool)
Deletes an empty directory and, if indicated, any subdirectories and files in the directory.
public static void Delete(string path, bool recursive)
Parameters
pathstringPath to directory
recursiveboolIf delete if subdirs exists
DeleteDirectoryStructure(string)
Deletes all files in the directory structure. It works also in a shared hosting environment.
public static void DeleteDirectoryStructure(string path)
Parameters
pathstringFull path of the directory to delete
EnumerateDirectories(string)
Returns an enumerable collection of directory names in a specified path.
public static IEnumerable<string> EnumerateDirectories(string path)
Parameters
pathstringThe relative or absolute path to the directory to search. This string is not case-sensitive.
Returns
- IEnumerable<string>
An enumerable collection of the full names (including paths) for the directories in the directory specified by
path.
Remarks
This method is identical to EnumerateDirectories(string, string) with the asterisk (*) specified as the search pattern, so it returns all subdirectories.
If you need to search subdirectories recursively, use the EnumerateDirectories(string, string, SearchOption) method, which enables you to specify a search of all subdirectories.
EnumerateDirectories(string, string)
Returns an enumerable collection of directory names that match a search pattern in a specified path.
public static IEnumerable<string> EnumerateDirectories(string path, string searchPattern)
Parameters
pathstringThe relative or absolute path to the directory to search. This string is not case-sensitive.
searchPatternstringSearch pattern.
Returns
- IEnumerable<string>
An enumerable collection of the full names (including paths) for the directories in the directory specified by
pathand that match the specified search pattern.
Remarks
If you need to search subdirectories recursively, use the EnumerateDirectories(string, string, SearchOption) method, which enables you to specify a search of all subdirectories.
EnumerateDirectories(string, string, SearchOption)
Returns an enumerable collection of directory names that match a search pattern in a specified path, and optionally searches subdirectories.
public static IEnumerable<string> EnumerateDirectories(string path, string searchPattern, SearchOption searchOption)
Parameters
pathstringThe relative or absolute path to the directory to search. This string is not case-sensitive.
searchPatternstringSearch pattern.
searchOptionSearchOptionOne of the enumeration values that specifies whether the search operation should include only the current directory or should include all subdirectories.
Returns
- IEnumerable<string>
An enumerable collection of the full names (including paths) for the directories in the directory specified by
pathand that match the specified search pattern and option.
EnumerateFiles(string)
Returns an enumerable collection of file names in a specified path.
public static IEnumerable<string> EnumerateFiles(string path)
Parameters
pathstringThe relative or absolute path to the directory to search. This string is not case-sensitive.
Returns
- IEnumerable<string>
An enumerable collection of the full names (including paths) for the files in the directory specified by
path.
Remarks
This method is identical to EnumerateFiles(string, string) with the asterisk (*) specified as the search pattern.
EnumerateFiles(string, string)
Returns an enumerable collection of file names that match a search pattern in a specified path.
public static IEnumerable<string> EnumerateFiles(string path, string searchPattern)
Parameters
pathstringThe relative or absolute path to the directory to search. This string is not case-sensitive.
searchPatternstringSearch pattern.
Returns
- IEnumerable<string>
An enumerable collection of the full names (including paths) for the files in the directory specified by
pathand that match the specified search pattern.
Exists(string)
Determines whether the given path refers to an existing directory on disk.
public static bool Exists(string path)
Parameters
pathstringPath to test
Returns
- bool
ExistsRelative(string)
Determines whether the specified file exists.
public static bool ExistsRelative(string path)
Parameters
pathstringPath to file
Returns
- bool
GetDirectories(string)
Returns the names of subdirectories (including their paths) in the specified directory.
public static string[] GetDirectories(string path)
Parameters
pathstringThe relative or absolute path to the directory to search. This string is not case-sensitive.
Returns
- string[]
An array of the full names (including paths) of subdirectories in the specified path, or an empty array if no directories are found.
Remarks
This method is identical to GetDirectories(string, string) with the asterisk (*) specified as the search pattern, so it returns all subdirectories.
If you need to search subdirectories recursively, use the GetDirectories(string, string, SearchOption) method, which enables you to specify a search of all subdirectories.
GetDirectories(string, string)
Returns the names of subdirectories (including their paths) that match the specified search pattern in the specified directory.
public static string[] GetDirectories(string path, string searchPattern)
Parameters
pathstringThe relative or absolute path to the directory to search. This string is not case-sensitive.
searchPatternstringSearch pattern.
Returns
- string[]
An array of the full names (including paths) of the subdirectories that match the search pattern in the specified directory, or an empty array if no directories are found.
Remarks
If you need to search subdirectories recursively, use the GetDirectories(string, string, SearchOption) method, which enables you to specify a search of all subdirectories.
GetDirectories(string, string, SearchOption)
Gets the names of the subdirectories (including their paths) that match the specified search pattern in the current directory, and optionally searches subdirectories.
public static string[] GetDirectories(string path, string searchPattern, SearchOption searchOption)
Parameters
pathstringThe relative or absolute path to the directory to search. This string is not case-sensitive.
searchPatternstringSearch pattern.
searchOptionSearchOptionOne of the enumeration values that specifies whether the search operation should include all subdirectories or only the current directory.
Returns
- string[]
An array of the full names (including paths) of the subdirectories that match the specified criteria, or an empty array if no directories are found.
GetDirectoryObject(ref string)
Gets the directory provider object for given path
public static AbstractDirectory GetDirectoryObject(ref string path)
Parameters
pathstringInput path, output is path relative to the returned storage provider
Returns
GetFiles(string)
Returns the names of files (including their paths) in the specified directory.
public static string[] GetFiles(string path)
Parameters
pathstringThe relative or absolute path to the directory to search. This string is not case-sensitive.
Returns
- string[]
An array of the full names (including paths) for the files in the specified directory, or an empty array if no files are found.
Remarks
This method is identical to GetFiles(string, string) with the asterisk (*) specified as the search pattern.
GetFiles(string, string)
Returns the names of files (including their paths) that match the specified search pattern in the specified directory.
public static string[] GetFiles(string path, string searchPattern)
Parameters
pathstringThe relative or absolute path to the directory to search. This string is not case-sensitive.
searchPatternstringSearch pattern.
Returns
- string[]
An array of the full names (including paths) for the files in the specified directory that match the specified search pattern, or an empty array if no files are found.
Move(string, string)
Moves a file or a directory and its contents to a new location.
public static void Move(string sourceDirName, string destDirName)
Parameters
sourceDirNamestringSource directory name
destDirNamestringDestination directory name
PrepareFilesForImport(string)
Prepares files for import. Converts them to media library.
[Obsolete("Method was not intended for public use and will be removed in the next version.")]
public static void PrepareFilesForImport(string path)
Parameters
pathstringPath.