DotNetBlog der DotNet-Blog Alles rund um Microsoft .NET – von  Sascha H. Baumann

MCTS Examen 70-536 – Filesystem

1 Star2 Stars3 Stars4 Stars5 Stars (Noch nicht bewertet. Seien Sie der/die Erste !)
Loading ... Loading ...

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:
    1. Filter (Filename, you can use wildcards)
    2. NotifyFilter (Defines, what changes causing a notification (One or more): Filename, Size, LastAccess etc)
    3. Path (Folder to be monitored)
Share and Enjoy:
  • Digg
  • del.icio.us
  • Mixx
  • Google Bookmarks
  • MisterWong.DE
  • Technorati
  • Webnews.de
  • YahooMyWeb

Hinterlasse eine Antwort

CAPTCHA-Bild CAPTCHA Audio
Bild neuladen

Bad Behavior has blocked 35 access attempts in the last 7 days.