Check If File Exists
How would I check if a file the user specifies exists. So the program won't pull an exception.
All help is appreciated thanks.
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Kirtan PatelPosted Nov 29, 2009, 12:29 AM
Here is Code how you can do this
if my answer helps you then check "Do you like this answer check box" please :)
using System.IO;
private void button1_Click(object sender, EventArgs e)
{
if (File.Exists("test.txt") == true)
{
MessageBox.Show("File Exist !!");
}
else
{
MessageBox.Show("file Not Exist!!");
}
}
Nick IngramPosted Nov 29, 2009, 12:41 AM