FileNotFoundException on file that exists!
-
Hi, I am running this code:
string fullFilename = "\\\\server\\share\\DL_JP_462153474_461535959_attest.JPG.pdf"; byte[] bytes = File.ReadAllBytes(fullFilename);
and get this exception: FileNotFoundException "Could not find file '\\\\server\\share\\DL_JP_462153474_461535959_attest.JPG.pdf'." The only problem is that the file does actually exist! Also, it works on files with shorter filenames in the same folder. For example: \\\\server\\share\\DL_JP_448856461_461530268_462153469.pdf Does anyone know what this is all about? :confused: -
Hi, I am running this code:
string fullFilename = "\\\\server\\share\\DL_JP_462153474_461535959_attest.JPG.pdf"; byte[] bytes = File.ReadAllBytes(fullFilename);
and get this exception: FileNotFoundException "Could not find file '\\\\server\\share\\DL_JP_462153474_461535959_attest.JPG.pdf'." The only problem is that the file does actually exist! Also, it works on files with shorter filenames in the same folder. For example: \\\\server\\share\\DL_JP_448856461_461530268_462153469.pdf Does anyone know what this is all about? :confused:It's *highly unlikely* that
System.IO.File
is wrong, but more likey that the path provided is incorrect in some way. try replacing this:string fullFilename = "\\\\server\\share\\DL_JP_462153474_461535959_attest.JPG.pdf";
with this
string fullFilename = @"\\server\share\DL_JP_462153474_461535959_attest.JPG.pdf";
If you use the string with the
@
symbol rather than your escaped version, you can copy the contents of the string you setfullFilename
and perform some manual checks( such as pasting the path\\server\share\DL_JP_462153474_461535959_attest.JPG.pdf into explorer).CCC solved so far: 2 (including a Hard One!)
-
It's *highly unlikely* that
System.IO.File
is wrong, but more likey that the path provided is incorrect in some way. try replacing this:string fullFilename = "\\\\server\\share\\DL_JP_462153474_461535959_attest.JPG.pdf";
with this
string fullFilename = @"\\server\share\DL_JP_462153474_461535959_attest.JPG.pdf";
If you use the string with the
@
symbol rather than your escaped version, you can copy the contents of the string you setfullFilename
and perform some manual checks( such as pasting the path\\server\share\DL_JP_462153474_461535959_attest.JPG.pdf into explorer).CCC solved so far: 2 (including a Hard One!)
So that is what the @ is for :) Thank you for your answer, but I have to admit that I screwed up, and the file actually doesn't exist :doh: I am working with some testdata, and someone placed an error there (possibly on purpose?) :| That is a lot of hours wasted... :( the difference_: DL_JP_462153474_461535959_attest.JPG.pdf DL_JP_462143474_461535959_attest.JPG.pdf
-
So that is what the @ is for :) Thank you for your answer, but I have to admit that I screwed up, and the file actually doesn't exist :doh: I am working with some testdata, and someone placed an error there (possibly on purpose?) :| That is a lot of hours wasted... :( the difference_: DL_JP_462153474_461535959_attest.JPG.pdf DL_JP_462143474_461535959_attest.JPG.pdf
Thomas ST wrote:
That is a lot of hours wasted...
We've all done this sort of thing!
CCC solved so far: 2 (including a Hard One!)