I am using Visual Studio 2012 with Update 3 installed. I am using C# targeting .NET framework 4.5.
I have a method that starts like this:
public void Open(System.String filePath)
{
if (!System.IO.File.Exists(filePath))
throw new FileNotFoundException(. . .);
. . .
}
The value of the filePath
parameter is this:
"C:\\Users\\Jonathan.DeCarlo\\Source\\Repos\\PoliticalClassifier\\src\\PoliticalClassifier.DataSource.Tests\\TestFiles\\Social_Economic_DataMicro.xlsx"
That path does indeed exist on my machine. This application is compiled as "Any CPU." I am running it on a machine with Windows 7 x64 installed. If I let the applicatoin run as an x64 process, the FileNotFoundException
is thrown even though the file does exist. If I force the application to run as an x86 process, then the the exception is NOT thrown (which should be the case).
Why does System.IO.File.Exists(filePath)
return a different result when the application is running as an x64 process as opposed to an x86 process?
Thank you for all of the comments. I tried a number of them and found that I could not reproduce the problem for any file other than the one I pointed to with my original code. Over the last couple days, I began to see my hard drive fail on me. After getting a new hard drive, setting it all up again, and running the aforementioned program, I no longer see this issue. I can't be 100% sure about this, but I'm going to assume that the file I was trying to open was corrupted by a failing hard drive. I apologize for the wild goose chase.
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