File Directory Operations

Using just File.Create will leave the file open, which probably isn't what you want.

You could use:

  1. using (File.Create(filename)) ; 

That looks slightly odd, mind you. You could use braces instead:

  1. using (File.Create(filename)) {} 

Or just call Dispose directly:

  1. File.Create(filename).Dispose(); 

Either way, if you're going to use this in more than one place you should probably consider wrapping it in a helper method,

e.g.

  1. public static void CreateEmptyFile(string filename)  
  2. {  
  3. File.Create(filename).Dispose();  

Note that calling Dispose directly instead of using a using statement doesn't really make much difference here as far as I can tell - the only way it could make a difference is if the thread were aborted between the call to File.Create and the call to Dispose. If that race condition exists, I suspect it would also exist in the using version, if the thread were aborted at the very end of the File.Create method, just before the value was returned...