How can I check whether the file exists?

Platform: ASP.NET| Category: Custom Controls

For all the File manipulation function the namespace System.IO; has to be included.

The existence of a file can be checked by the following syntax , File.Exists(path);
where path is the path of the file name.

The code can be as.


if(File.Exists('C:\\dict.txt'))
{
	Response.Write('File Exists');
}
else
{
	Response.Write('File Not Found');
}

Share with

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.