Friday 4 March 2011

System.IO.FileInfo - Delete a file

Just something I stumbled across today.
Why if you are creating an instance of the System.IO.FileInfo class do you then also have to supply the file path if you want to call the Delete method?


FileInfo TheFile = new FileInfo(logoPath);
if (TheFile.Exists)
{
    File.Delete(logoPath);

}


Now let me quote the class summary for you


Provides instance methods for the creation, copying, deletion, moving, and opening of files, and aids in the creation of System.IO.FileStream objects.

I beg to differ!

Whilst the methods are instance (in the sense they are not declared as static)  but surely having to supply the path when you call Delete is a contradiction.


Curiously though I notice that the Delete method

public override void Delete();


Does not actually specify a parameter.

So where does it come from?
Have I missed something?

No comments:

Post a Comment