Saturday, July 17, 2010

Check If File / Directory Exists

In this and the next posts I want to show some basic operations which can be performed on files and directories. In C# we therefor mostly use the classes System.IO.File and System.IO.Directory.
This post shows how to check whether a file or directory already exists:
bool DirectoryExists = System.IO.Directory.Exists("C:\\test");
bool FileExists = System.IO.File.Exists("C:\\testfile.txt");

No comments:

Post a Comment