Exposes static methods for creating, moving, and enumerating through directories and subdirectories. This class cannot be inherited.
See Also: Directory Members
Use the System.IO.Directory class for typical operations such as copying, moving, renaming, creating, and deleting directories.
To create a directory, use one of the Directory.CreateDirectory(string) methods.
To delete a directory, use one of the Directory.Delete(string) methods.
To get or set the current directory for an app, use the Directory.GetCurrentDirectory or Directory.SetCurrentDirectory(string) method.
To manipulate DateTime information related to the creation, access, and writing of a directory, use methods such as Directory.SetLastAccessTime(string, DateTime) and Directory.SetCreationTime(string, DateTime).
The static methods of the System.IO.Directory class perform security checks on all methods. If you are going to reuse an object several times, consider using the corresponding instance method of System.IO.DirectoryInfo instead, because the security check will not always be necessary.
If you are performing only one directory-related action, it might be more efficient to use a static System.IO.Directory method rather than a corresponding System.IO.DirectoryInfo instance method. Most System.IO.Directory methods require the path to the directory that you are manipulating.
In members that accept a string path parameter, that path must be well-formed or an exception is raised. For example, if a path is fully qualified but begins with a space (" c:\temp"), the path string isn't trimmed, so the path is considered malformed and an exception is raised. In addition, a path or a combination of paths cannot be fully qualified twice. For example, "c:\temp c:\windows" also raises an exception. Ensure that your paths are well-formed when using methods that accept a path string. For more information see System.IO.Path.
In members that accept a path, the path can refer to a file or a directory. You can use a full path, a relative path, or a Universal Naming Convention (UNC) path for a server and share name. For example, all the following are acceptable paths:
"c:\\MyDir" in C#, or "c:\MyDir" in Visual Basic.
"MyDir\\MySubdir" in C#, or "MyDir\MySubDir" in Visual Basic.
"\\\\MyServer\\MyShare" in C#, or "\\MyServer\MyShare" in Visual Basic.
By default, full read/write access to new directories is granted to all users. However, the app must have the correct security to access existing directories.
To demand permissions for a directory and all its subdirectories, end the path string with the directory separator character. (For example, "C:\Temp\" grants access to C:\Temp\ and all its subdirectories.) To demand permissions only for a specific directory, end the path string with a period. (For example, "C:\Temp\." grants access only to C:\Temp\, not to its subdirectories.)
In members that accept a searchPattern parameter, the search string can be any combination of literal characters and two wildcard characters; * and ?. This parameter does not recognize regular expressions. For more information, see the Directory.EnumerateDirectories(string, string) method or any other method that uses the searchPattern parameter.
For a list of common I/O tasks, see Common I/O Tasks.
System.IO.Directory and System.IO.DirectoryInfo are not supported for use in win8_appstore_long apps. For information about how to access files and folders in win8_appstore_long apps, see tp://msdn.microsoft.com/library/windows/apps/hh758319.aspx.