I'm being completely confused here folks,
My code throws an exception because File.Exists() returns false
public override sealed TCargo ReadFile(string fileName)
{
if (!File.Exists(fileName))
{
throw new ArgumentException("Provided file name does not exist", "fileName");
}
Visual studio breaks at the throw statement, and I immediately check the value of File.Exists(fileName)
in the immediate window. It returns true
. When I drag the breakpoint back up to the if statement and execute it again, it throws again.
fileName is an absolute path to a file. I'm not creating the file, nor writing to it (it's there all along). If I paste the path into the open dialog in Notepad, it reads the file without problems.
The code is executing in a background worker. It's the only complicating factor I can think of. I am positive the file has not been opened already, either in the worker thread or elsewhere.
What's going on here?