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.
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
Kirtan PatelRank #292 · 8.6K reputationPosted Nov 28, 2009, 7:29 PM EST
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 Ingram12 reputationPosted Nov 28, 2009, 7:41 PM EST