A
Anthony Papillion
Hello Everyone,
I'm writing some code that needs to check if a file exists or not. I'm
using the System.IO's File.Exist() method and it's either misreporting
or I am not fully understanding how this class works. Here's what I am
doing:
if(File.Exist("app.cfg")){
FileStream oFile = new FileStream("app.cfg", FileMode.Open,
FileAccess.Read);
StreamReader oReader = new StreamReader(oFile);
}
Simple enoiugh, right? Basically, if the file exists, create a new
FileStream and attach a StreamReader to it. But, for some reason, even
though the file DOES NOT exist, the code is still validating the
File.Exist() method and trying to open the file.
Is this code wrong? Could I be experiencing a problem with the
compiler? Can someone give a guy a clue? lol
Thanks in advance,
Anthony
I'm writing some code that needs to check if a file exists or not. I'm
using the System.IO's File.Exist() method and it's either misreporting
or I am not fully understanding how this class works. Here's what I am
doing:
if(File.Exist("app.cfg")){
FileStream oFile = new FileStream("app.cfg", FileMode.Open,
FileAccess.Read);
StreamReader oReader = new StreamReader(oFile);
}
Simple enoiugh, right? Basically, if the file exists, create a new
FileStream and attach a StreamReader to it. But, for some reason, even
though the file DOES NOT exist, the code is still validating the
File.Exist() method and trying to open the file.
Is this code wrong? Could I be experiencing a problem with the
compiler? Can someone give a guy a clue? lol
Thanks in advance,
Anthony