Class DirectoryInfo
Exposes instance methods for creating, moving, and enumerating through directories and subdirectories.
public abstract class DirectoryInfo
- Inheritance
-
objectDirectoryInfo
- Derived
- Extension Methods
Constructors
DirectoryInfo()
Creates new instance.
protected DirectoryInfo()
Properties
CreationTime
Creation time.
public abstract DateTime CreationTime { get; set; }
Property Value
- DateTime
Exists
Whether directory exists.
public abstract bool Exists { get; set; }
Property Value
- bool
FullName
Full name of directory (whole path).
public abstract string FullName { get; set; }
Property Value
- string
LastWriteTime
Last write time to directory.
public abstract DateTime LastWriteTime { get; set; }
Property Value
- DateTime
Name
Name of directory (without path).
public abstract string Name { get; set; }
Property Value
- string
Parent
Parent directory.
public abstract DirectoryInfo Parent { get; }
Property Value
Methods
CreateSubdirectory(string)
Creates subdirectory.
public DirectoryInfo CreateSubdirectory(string subdir)
Parameters
subdir
stringSubdirectory to create
Returns
CreateSubdirectoryInternal(string)
Creates subdirectory.
protected abstract DirectoryInfo CreateSubdirectoryInternal(string subdir)
Parameters
subdir
stringSubdirectory to create
Returns
Delete()
Deletes directory.
public void Delete()
DeleteInternal()
Deletes directory.
protected abstract void DeleteInternal()
EnumerateDirectories()
Returns an enumerable collection of directory information in the current directory.
public IEnumerable<DirectoryInfo> EnumerateDirectories()
Returns
- IEnumerable<DirectoryInfo>
An enumerable collection of directories in the current directory.
EnumerateDirectories(string)
Returns an enumerable collection of directory information that matches a specified search pattern.
public IEnumerable<DirectoryInfo> EnumerateDirectories(string searchPattern)
Parameters
searchPattern
stringSearch pattern.
Returns
- IEnumerable<DirectoryInfo>
An enumerable collection of directories that matches
searchPattern
.
EnumerateDirectories(string, SearchOption)
Returns an enumerable collection of directory information that matches a specified search pattern and search subdirectory option.
public IEnumerable<DirectoryInfo> EnumerateDirectories(string searchPattern, SearchOption searchOption)
Parameters
searchPattern
stringSearch pattern.
searchOption
SearchOptionOne of the enumeration values that specifies whether the search operation should include only the current directory or all subdirectories.
Returns
- IEnumerable<DirectoryInfo>
An enumerable collection of directories that matches
searchPattern
andsearchOption
.
EnumerateDirectoriesInternal(string, SearchOption)
Returns an enumerable collection of directory information that matches a specified search pattern and search subdirectory option.
protected abstract IEnumerable<DirectoryInfo> EnumerateDirectoriesInternal(string searchPattern, SearchOption searchOption)
Parameters
searchPattern
stringSearch pattern.
searchOption
SearchOptionOne of the enumeration values that specifies whether the search operation should include only the current directory or all subdirectories.
Returns
- IEnumerable<DirectoryInfo>
An enumerable collection of directories that matches
searchPattern
andsearchOption
.
EnumerateFiles()
Returns an enumerable collection of file information in the current directory.
public IEnumerable<FileInfo> EnumerateFiles()
Returns
- IEnumerable<FileInfo>
An enumerable collection of the files in the current directory.
EnumerateFiles(string)
Returns an enumerable collection of file information that matches a search pattern.
public IEnumerable<FileInfo> EnumerateFiles(string searchPattern)
Parameters
searchPattern
stringSearch pattern.
Returns
- IEnumerable<FileInfo>
An enumerable collection of files that matches
searchPattern
.
EnumerateFiles(string, SearchOption)
Returns an enumerable collection of file information that matches a specified search pattern and search subdirectory option.
public IEnumerable<FileInfo> EnumerateFiles(string searchPattern, SearchOption searchOption)
Parameters
searchPattern
stringSearch pattern.
searchOption
SearchOptionOne of the enumeration values that specifies whether the search operation should include only the current directory or all subdirectories.
Returns
- IEnumerable<FileInfo>
An enumerable collection of files that matches
searchPattern
andsearchOption
.
EnumerateFilesInternal(string, SearchOption)
Returns an enumerable collection of file information that matches a specified search pattern and search subdirectory option.
protected abstract IEnumerable<FileInfo> EnumerateFilesInternal(string searchPattern, SearchOption searchOption)
Parameters
searchPattern
stringSearch pattern.
searchOption
SearchOptionOne of the enumeration values that specifies whether the search operation should include only the current directory or all subdirectories.
Returns
- IEnumerable<FileInfo>
An enumerable collection of files that matches
searchPattern
andsearchOption
.
GetDirectories()
Returns the subdirectories of the current directory.
public DirectoryInfo[] GetDirectories()
Returns
GetDirectories(string)
Returns the subdirectories of the current directory.
public DirectoryInfo[] GetDirectories(string searchPattern)
Parameters
searchPattern
stringSearch pattern
Returns
GetDirectories(string, SearchOption)
Returns an array of directories in the current DirectoryInfo matching the given search criteria and using a value to determine whether to search subdirectories.
public DirectoryInfo[] GetDirectories(string searchPattern, SearchOption searchOption)
Parameters
searchPattern
stringSearch pattern
searchOption
SearchOptionSpecifies whether to search the current directory, or the current directory and all subdirectories.
Returns
GetDirectoriesInternal(string, SearchOption)
Returns an array of directories in the current DirectoryInfo matching the given search criteria and using a value to determine whether to search subdirectories.
protected abstract DirectoryInfo[] GetDirectoriesInternal(string searchPattern, SearchOption searchOption)
Parameters
searchPattern
stringSearch pattern
searchOption
SearchOptionSpecifies whether to search the current directory, or the current directory and all subdirectories.
Returns
GetFiles()
Returns a file list from the current directory.
public FileInfo[] GetFiles()
Returns
- FileInfo[]
GetFiles(string)
Returns a file list from the current directory.
public FileInfo[] GetFiles(string searchPattern)
Parameters
searchPattern
stringSearch pattern
Returns
- FileInfo[]
GetFiles(string, SearchOption)
Returns a file list from the current directory.
public FileInfo[] GetFiles(string searchPattern, SearchOption searchOption)
Parameters
searchPattern
stringSearch pattern
searchOption
SearchOptionSearch options
Returns
- FileInfo[]
GetFilesInternal(string, SearchOption)
Returns a file list from the current directory.
protected abstract FileInfo[] GetFilesInternal(string searchPattern, SearchOption searchOption)
Parameters
searchPattern
stringSearch pattern
searchOption
SearchOptionSearch options
Returns
- FileInfo[]
GetSearchCondition(string)
Returns search condition delegate.
protected Func<string, bool> GetSearchCondition(string searchPattern)
Parameters
searchPattern
stringCan be a combination of literal and wildcard characters, but doesn't support regular expressions. Supports only
*
and?
Returns
- Func<string, bool>
New(string)
Creates new instance of directory info object.
public static DirectoryInfo New(string path)
Parameters
path
stringPath to directory