MCTS Examen 70-536 – Filesystem
Hi there
We now leave types behind and go to the input/output chapter. I have to say, writing along while learning takes more time then just reading, but i hope it pays out at the end my having more information stuck in my brain ;o)
Drive Enumerating
- Use DriveInfo.GetDrives to get a List of Drives connected to the system
- You get a Collection over which you can loop
- Available Information: AvailableFreeSpace, DriveFormat, DriveType, IsReady, Name, RootDirectory,TotalFreeSpace, TotalSize, VolumeLabel
Files and Folders
- You can browse a folder by using an instance of DirectoyInfo and call .GetFiles or .GetDirectories
- You can create a directory by using an instance of DirectoryInfo and call .Create
- You can check if a directory Exists by DirectoryInfo.Exists
- Static File Operations: File.Create, File.CreateText, File.Copy, File.Move, File.Delete
- Alternative: Use an instance of FileInfo and call .Create, .CreateText, .CopyTo, .MoveTo, .Delete
Filesystem Monitoring
- Use System.IO.FileSystemWatcher (responds to updated, new and renamed files etc)
- FSW works Eventbased (Changed-Event, Create-Event, Delete-Event, Rename-Event etc.) and provides FileSystemEventArgs (except Rename, this provides RenamedEventArgs
- You can configure the Watcher with:
- Filter (Filename, you can use wildcards)
- NotifyFilter (Defines, what changes causing a notification (One or more): Filename, Size, LastAccess etc)
- Path (Folder to be monitored)


