Hey this is going to be one of those dumb questions. I am trying to pick up a file on my local system and I keep getting a FileNotFoundException
thrown.
Someone set me straight please :)
if( File.Exists(@"C:\logs\hw-healthways-prod_2009-08-26.tar")) { Console.WriteLine("Yay"); } else { throw new FileNotFoundException(); }
Tried moving the file into the same location as the executing application and did the following:
if( File.Exists("hw-healthways-prod_2009-08-26.tar"))
Same thing.
Then I made a random txt file and parked it there too.. "me.txt"
And it works?! So you thing the file name is the problem?
Try doing Directory.GetFiles(@"C:\logs")
. It's possible that the file in question has odd characters that are getting interpreted one way by Windows Explorer (presumably where you're reading "the file's property" from?) but a different way by the .NET Framework. This can happen if you have UTF-8 characters in the filename (perhaps an en dash?).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With