People here completely confuse me,
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 down into a throw statement, and I immediately check the value of File.Exists(fileName) in the immediate window. It returns true . When I drag the breakpoint into the if statement and execute it again, it throws again.
fileName is the absolute path to the file. I do not create a file or write to it (it is there all the time). If I paste the path into an open dialog in Notepad, it will read the file without any problems.
The code runs in the background worker. This is the only difficult factor that I can think of. I am sure that the file was no longer open, either in the workflow or elsewhere.
What's going on here?
source share