Abstracting the File System

Following on from my post about OSS I thought I would illustrate how cool OSS can be.

The day before that post was published I was working on a program that required the file system. All you good developers are going to know that the file system is a dependency and dependencies are bad and this post will probably be a bit like preaching to the choir however I thought it was worth posting.

So you have a a method similar to this:

1
2
3
4
5
6
7
8
9
10
11
public void DoSomethingCool()
{
  //do some stuff now write to file

  FileInfo f = new FileInfo("C:\\Mytext.txt")
  using(StreamWriter w = f.CreateText())
  {
    w.WriteLine("This blog post is cool");
    w.Close();
  }
}

You are [...Read More...]