Directory Class and DirectoryInfo Class
Part of my 2008 study notes for exam 70-536 (.NET Framework 2.0).
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());
You May Also Like
ArrayList Class
Resizeable, unordered, index-based collection. Suffers from boxing/unboxing when working with value types. Implements IEnumerator, allowing foreach…
BinaryReader Class and BinaryWriter Class
Used to read and write binary data from streams. Call the correct Read methods when using a BinaryReader.
BitArray Class
Contains an array of true/false values. Resizable through the Length property. Supports bitwise operations.



