Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. FileNotFoundException on file that exists!

FileNotFoundException on file that exists!

Scheduled Pinned Locked Moved C#
sysadminhelptutorialquestion
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    Thomas ST
    wrote on last edited by
    #1

    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:

    K 1 Reply Last reply
    0
    • T Thomas ST

      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:

      K Offline
      K Offline
      Keith Barrow
      wrote on last edited by
      #2

      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 set fullFilename 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!)

      T 1 Reply Last reply
      0
      • K Keith Barrow

        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 set fullFilename 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!)

        T Offline
        T Offline
        Thomas ST
        wrote on last edited by
        #3

        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

        K 1 Reply Last reply
        0
        • T Thomas ST

          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

          K Offline
          K Offline
          Keith Barrow
          wrote on last edited by
          #4

          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!)

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups