System::IO::Directory Class Reference

Contains methods for manipulating directories. More...

Public Types

using StringEnumerablePtr = SharedPtr< Collections::Generic::IEnumerable< String > >
 An alias for a shared pointer to IEnumerable object that enumerates over a set of String objects. More...
 

Static Public Member Functions

static void CreateDirectory_ (const String &path)
 
static void Delete (const String &path, bool recursive=false)
 
static StringEnumerablePtr EnumerateDirectories (const String &path, const String &searchPattern=u"*", SearchOption searchOption=SearchOption::TopDirectoryOnly)
 
static StringEnumerablePtr EnumerateFiles (const String &path, const String &searchPattern=u"*", SearchOption searchOption=SearchOption::TopDirectoryOnly)
 
static StringEnumerablePtr EnumerateFileSystemEntries (const String &path, const String &searchPattern=u"*", SearchOption searchOption=SearchOption::TopDirectoryOnly)
 
static ArrayPtr< StringGetDirectories (const String &path, const String &searchPattern=u"*", SearchOption searchOption=SearchOption::TopDirectoryOnly)
 
static ArrayPtr< StringGetFiles (const String &path, const String &searchPattern=u"*", SearchOption searchOption=SearchOption::TopDirectoryOnly)
 
static ArrayPtr< StringGetFileSystemEntries (const String &path, const String &searchPattern=u"*", SearchOption searchOption=SearchOption::TopDirectoryOnly)
 
static ArrayPtr< StringGetLogicalDrives ()
 
static bool Exists (const String &path)
 
static DateTime GetCreationTime (const String &path)
 
static DateTime GetCreationTimeUtc (const String &path)
 
static DateTime GetLastAccessTime (const String &path)
 
static DateTime GetLastAccessTimeUtc (const String &path)
 
static DateTime GetLastWriteTime (const String &path)
 
static DateTime GetLastWriteTimeUtc (const String &path)
 
static void SetCreationTime (const String &path, DateTime date)
 
static void SetCreationTimeUtc (const String &path, DateTime date)
 
static void SetLastAccessTime (const String &path, DateTime date)
 
static void SetLastAccessTimeUtc (const String &path, DateTime date)
 
static void SetLastWriteTime (const String &path, DateTime date)
 
static void SetLastWriteTimeUtc (const String &path, DateTime date)
 
static String GetCurrentDirectory ()
 Returns the full name (including path) of the current directory. More...
 
static String GetDirectoryRoot (const String &path)
 
static DirectoryInfoPtr GetParent (const String &path)
 
static void Move (const String &sourceDirName, const String &destDirName)
 
static void SetCurrentDirectory (const String &path)
 

Detailed Description

Contains methods for manipulating directories.

Member Typedef Documentation

◆ StringEnumerablePtr

An alias for a shared pointer to IEnumerable object that enumerates over a set of String objects.

Member Function Documentation

◆ CreateDirectory_()

static void System::IO::Directory::CreateDirectory_ ( const String path)
static

Creates all directories in the specified path if those don't exist.

Parameters
pathThe path containing the directories to create

◆ Delete()

static void System::IO::Directory::Delete ( const String path,
bool  recursive = false 
)
static

Removes the specified file or directory. Does not throw.

Parameters
pathThe path to the directory or file to be removed
recursiveIf path spacifies a non-empty directory then recursive specifies if if all directory's content should be removed recursively; if the directory specified by path is not empty and recursive is 'false' then the operation fails

◆ EnumerateDirectories()

static StringEnumerablePtr System::IO::Directory::EnumerateDirectories ( const String path,
const String searchPattern = u"*",
SearchOption  searchOption = SearchOption::TopDirectoryOnly 
)
static

Searches for the directories that satisfy the specified search criteria either in the specified directory or in the whole directory tree rooted in the specified directory.

Parameters
pathFull or relative path to the directory to search in
seachPatterThe name pattern of the directories to search for
searchOptionSpecifies whether the search has to be performed in the specified directory only or in the whole directory tree rooted in the specified directory
Returns
The enumerable collection of full paths of the found directories whose names match searchPattern

◆ EnumerateFiles()

static StringEnumerablePtr System::IO::Directory::EnumerateFiles ( const String path,
const String searchPattern = u"*",
SearchOption  searchOption = SearchOption::TopDirectoryOnly 
)
static

Searches for the files that satisfy the specified search criteria either in the specified directory or in the whole directory tree rooted in the specified directory.

Parameters
pathFull or relative path to the directory to search in
seachPatterThe name pattern of the files to search for
searchOptionSpecifies whether the search has to be performed in the specified directory only or in the whole directory tree rooted in the specified directory
Returns
The enumerable collection of full paths of the found files whose names match searchPattern

◆ EnumerateFileSystemEntries()

static StringEnumerablePtr System::IO::Directory::EnumerateFileSystemEntries ( const String path,
const String searchPattern = u"*",
SearchOption  searchOption = SearchOption::TopDirectoryOnly 
)
static

Searches for the files and directories that satisfy the specified search criteria either in the specified directory or in the whole directory tree rooted in the specified directory.

Parameters
pathFull or relative path to the directory to search in
seachPatterThe name pattern of the files and directories to search for
searchOptionSpecifies whether the search has to be performed in the specified directory only or in the whole directory tree rooted in the specified directory
Returns
The enumerable collection of full paths of the found files and directories whose names match searchPattern

◆ Exists()

static bool System::IO::Directory::Exists ( const String path)
static

Determines if the specified path refers to existing directory.

Parameters
pathThe path to check
Returns
True if the specified path refers to existing directory, otherwise - false

◆ GetCreationTime()

static DateTime System::IO::Directory::GetCreationTime ( const String path)
static

Returns the creation time of the specified entity as local time.

Parameters
pathThe entity whose creating time to retrieve
Returns
A DateTime object representing the creation time of the specified entity as local time

◆ GetCreationTimeUtc()

static DateTime System::IO::Directory::GetCreationTimeUtc ( const String path)
static

Returns the creation time of the specified entity as UTC time.

Parameters
pathThe entity whose creating time to retrieve
Returns
A DateTime object representing the creation time of the specified entity as UTC time

◆ GetCurrentDirectory()

static String System::IO::Directory::GetCurrentDirectory ( )
static

Returns the full name (including path) of the current directory.

◆ GetDirectories()

static ArrayPtr<String> System::IO::Directory::GetDirectories ( const String path,
const String searchPattern = u"*",
SearchOption  searchOption = SearchOption::TopDirectoryOnly 
)
static

Searches for the directories that satisfy the specified search criteria either in the specified directory or in the whole directory tree rooted in the specified directory.

Parameters
pathFull or relative path to the directory to search in
seachPatterThe name pattern of the directories to search for
searchOptionSpecifies whether the search has to be performed in the specified directory only or in the whole directory tree rooted in the specified directory
Returns
An array of full paths of the found directories whose names match searchPattern

◆ GetDirectoryRoot()

static String System::IO::Directory::GetDirectoryRoot ( const String path)
static

Returns the root directory of the specified path.

Parameters
pathA path from which a root directory is to be obtained
Returns
The name of the root directory in path

◆ GetFiles()

static ArrayPtr<String> System::IO::Directory::GetFiles ( const String path,
const String searchPattern = u"*",
SearchOption  searchOption = SearchOption::TopDirectoryOnly 
)
static

Searches for the files that satisfy the specified search criteria either in the specified directory or in the whole directory tree rooted in the specified directory.

Parameters
pathFull or relative path to the directory to search in
seachPatterThe name pattern of the files to search for
searchOptionSpecifies whether the search has to be performed in the specified directory only or in the whole directory tree rooted in the specified directory
Returns
An array of full paths of the found files whose names match searchPattern

◆ GetFileSystemEntries()

static ArrayPtr<String> System::IO::Directory::GetFileSystemEntries ( const String path,
const String searchPattern = u"*",
SearchOption  searchOption = SearchOption::TopDirectoryOnly 
)
static

Searches for the files and directories that satisfy the specified search criteria either in the specified directory or in the whole directory tree rooted in the specified directory.

Parameters
pathFull or relative path to the directory to search in
seachPatterThe name pattern of the files and directories to search for
searchOptionSpecifies whether the search has to be performed in the specified directory only or in the whole directory tree rooted in the specified directory
Returns
An array of full paths of the found files and directories whose names match searchPattern

◆ GetLastAccessTime()

static DateTime System::IO::Directory::GetLastAccessTime ( const String path)
static

Returns the last access time of the specified entity as local time.

Parameters
pathThe entity whose last access time to retrieve
Returns
A DateTime object representing the last access time of the specified entity as local time

◆ GetLastAccessTimeUtc()

static DateTime System::IO::Directory::GetLastAccessTimeUtc ( const String path)
static

Returns the last access time of the specified entity as UTC time.

Parameters
pathThe entity whose last access time to retrieve
Returns
A DateTime object representing the last access time of the specified entity as UTC time

◆ GetLastWriteTime()

static DateTime System::IO::Directory::GetLastWriteTime ( const String path)
static

Returns the last write time of the specified entity as local time.

Parameters
pathThe entity whose last write time to retrieve
Returns
A DateTime object representing the last write time of the specified entity as local time

◆ GetLastWriteTimeUtc()

static DateTime System::IO::Directory::GetLastWriteTimeUtc ( const String path)
static

Returns the last write time of the specified entity as UTC time.

Parameters
pathThe entity whose last write time to retrieve
Returns
A DateTime object representing the last write time of the specified entity as UTC time

◆ GetLogicalDrives()

static ArrayPtr<String> System::IO::Directory::GetLogicalDrives ( )
static

NOT IMPLEMENTED

Exceptions
IOExceptionAlways

◆ GetParent()

static DirectoryInfoPtr System::IO::Directory::GetParent ( const String path)
static

Returns a shared pointer to DirectoryInfo object representing the parent directory of the specified entity.

Parameters
pathThe path to the entity whose parent is to be obtained
Returns
A shared pointer to DirectoryInfo object representing the parent directory of the entity specified by path

◆ Move()

static void System::IO::Directory::Move ( const String sourceDirName,
const String destDirName 
)
static

Moves the specified entity to the new location. If the entity to move is a directory, it is moved with all its content.

Parameters
sourceDirNameA direcotry or file to move
destDirNameThe new location of sourceDirName

◆ SetCreationTime()

static void System::IO::Directory::SetCreationTime ( const String path,
DateTime  date 
)
static

Sets the creation time of the specified entity as local time.

Parameters
pathThe entity whose creating time to set
dateA DateTime object representing the time to set as local time

◆ SetCreationTimeUtc()

static void System::IO::Directory::SetCreationTimeUtc ( const String path,
DateTime  date 
)
static

Sets the creation time of the specified entity as UTC time.

Parameters
pathThe entity whose creating time to set
dateA DateTime object representing the time to set as UTC time

◆ SetCurrentDirectory()

static void System::IO::Directory::SetCurrentDirectory ( const String path)
static

Sets the current directory.

Parameters
pathThe path to the directory to make current

◆ SetLastAccessTime()

static void System::IO::Directory::SetLastAccessTime ( const String path,
DateTime  date 
)
static

Sets the last access time of the specified entity as local time.

Parameters
pathThe entity whose last access time to set
dateA DateTime object representing the time to set as local time

◆ SetLastAccessTimeUtc()

static void System::IO::Directory::SetLastAccessTimeUtc ( const String path,
DateTime  date 
)
static

Sets the last access time of the specified entity as UTC time.

Parameters
pathThe entity whose last access time to set
dateA DateTime object representing the time to set as UTC time

◆ SetLastWriteTime()

static void System::IO::Directory::SetLastWriteTime ( const String path,
DateTime  date 
)
static

Sets the last write time of the specified entity as local time.

Parameters
pathThe entity whose last write time to set
dateA DateTime object representing the time to set as local time

◆ SetLastWriteTimeUtc()

static void System::IO::Directory::SetLastWriteTimeUtc ( const String path,
DateTime  date 
)
static

Sets the last write time of the specified entity as UTC time.

Parameters
pathThe entity whose last write time to set
dateA DateTime object representing the time to set as UTC time