The example in this article describes how ASP.net checks for the existence of directories or files on the server. Share to everyone for your reference. The specific methods are analyzed as follows:
asp.net for us to provide a file system objects, for the directory and file to determine whether there are System.IO.File.Exists and System.IO.Directory.Exists can be, see below two examples of applications.
To determine whether a file exists:
Copy Code code as follows:
Using System.IO; Also need namespaces, don't forget
if (System.IO.File.Exists ("C:aaa.txt"))//Note the double quote path should be double slash
{
########## have aaa.txt files!
}
To determine whether a directory exists:
Copy Code code as follows:
Using System.IO; Also need namespaces, don't forget
if (System.IO.Directory.Exists ("c:www.jb51.net"))//Note the double quote path should be double slash
{
########## has a AAA folder!
}
I hope this article will help you with the ASP.net program design.