I am getting this error.
File not found.
StreamReader sreader = new StreamReader(@"c:\text.txt");
string strcontent = sreader.ReadToEnd();
How to check file available in the particular location.
I am getting this error.
File not found.
StreamReader sreader = new StreamReader(@"c:\text.txt");
string strcontent = sreader.ReadToEnd();
How to check file available in the particular location.
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 attend5days leftRegister
SenthilkumarRank #387 · 6.5K reputationPosted Apr 19, 2012, 12:51 AM EDT
You have to do file check whether file exists in the position or not.
Otherwise it will give the run time error.
The File class provides the method to check file exists or not in the given path.
you can do the check like the following.
Hope this will help you.
Krishna GaradRank #191 · 12.8K reputationPosted Apr 18, 2012, 9:58 PM EDT
if (File.Exists(@"c:\test.txt"))
{
//your stuff here
}
Sam HobbsRank #107 · 20.5K reputationPosted Apr 19, 2012, 5:09 PM EDT
Are you sure you want "text" and not "test"? You might have a slight mis-spelling. If so then the technique I describe above would give you a really big clue.