Directory Class and DirectoryInfo Class

Overview

  • DirectoryInfo
    • Extends FileSystemInfo with directory specific operations.
    • It is possible to create a DirectoryInfo object for a non-existent directory.
    • GetDirectories and GetFiles allow the use of wildcards.

Examples

Create SubDir

DirectoryInfo a = new DirectoryInfo(@"C:\Public\Test");
 
a.Create();
a.CreateSubdirectory("Subtest");
 
foreach (var dir in a.Parent.GetDirectories())
{
    Console.WriteLine(dir.FullName);
}

Set Current Directory

Console.WriteLine(Directory.GetCurrentDirectory()); // Returns a 'bin' Debug/Release directory
Directory.SetCurrentDirectory(@"C:\Public\Test");
Console.WriteLine(Directory.GetCurrentDirectory());
 
learning/exam70-536/dirinfo.txt · Last modified: 2008/08/27 11:14 by david
 
Except where otherwise noted, content on this wiki is licensed under the following license:CC Attribution-Noncommercial-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki