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. C# Cannot find file

C# Cannot find file

Scheduled Pinned Locked Moved C#
csharp
9 Posts 5 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
    tjDieHard
    wrote on last edited by
    #1

    I am writing a small Wx app and need to access a file on the HDD to fill a combobox. I am using StreamReader and ReadLine to get it into the box. I have moved the file to the root, the file has no permissions set. Each time that I run the app it errors to the catch and tells me that it cannot find the file. I have tried File.Exists( file ) and it also tells me that it is not there. I have used @"c:\nex_tex.txt" and "c:\\nex_tex.txt" with no success. If I didn't see it with my own eyes I wouldn't believe that it was there. Anyway I am new to C# and obviously am missing something. Thanks in Advance DH

    R G M 3 Replies Last reply
    0
    • T tjDieHard

      I am writing a small Wx app and need to access a file on the HDD to fill a combobox. I am using StreamReader and ReadLine to get it into the box. I have moved the file to the root, the file has no permissions set. Each time that I run the app it errors to the catch and tells me that it cannot find the file. I have tried File.Exists( file ) and it also tells me that it is not there. I have used @"c:\nex_tex.txt" and "c:\\nex_tex.txt" with no success. If I didn't see it with my own eyes I wouldn't believe that it was there. Anyway I am new to C# and obviously am missing something. Thanks in Advance DH

      R Offline
      R Offline
      ricardojb
      wrote on last edited by
      #2

      what do you mean with the file has no permissions set, if it has no permissions set it won't be accessible to anybody.

      T 1 Reply Last reply
      0
      • R ricardojb

        what do you mean with the file has no permissions set, if it has no permissions set it won't be accessible to anybody.

        T Offline
        T Offline
        tjDieHard
        wrote on last edited by
        #3

        Not read only, or hidden I meant. My mistake in words.

        1 Reply Last reply
        0
        • T tjDieHard

          I am writing a small Wx app and need to access a file on the HDD to fill a combobox. I am using StreamReader and ReadLine to get it into the box. I have moved the file to the root, the file has no permissions set. Each time that I run the app it errors to the catch and tells me that it cannot find the file. I have tried File.Exists( file ) and it also tells me that it is not there. I have used @"c:\nex_tex.txt" and "c:\\nex_tex.txt" with no success. If I didn't see it with my own eyes I wouldn't believe that it was there. Anyway I am new to C# and obviously am missing something. Thanks in Advance DH

          G Offline
          G Offline
          Guffa
          wrote on last edited by
          #4

          tjDieHard wrote:

          the file has no permissions set

          Are you sure? It really sounds like a permission problem. Click the Advanced button in the security tab of the file properties. There you can see all permissions for the file. --- b { font-weight: normal; }

          T 1 Reply Last reply
          0
          • G Guffa

            tjDieHard wrote:

            the file has no permissions set

            Are you sure? It really sounds like a permission problem. Click the Advanced button in the security tab of the file properties. There you can see all permissions for the file. --- b { font-weight: normal; }

            T Offline
            T Offline
            tjDieHard
            wrote on last edited by
            #5

            I have checked all,and all is okay. If it was a permission would it error this way or would I get the access denied type error? I m lost

            C G 2 Replies Last reply
            0
            • T tjDieHard

              I have checked all,and all is okay. If it was a permission would it error this way or would I get the access denied type error? I m lost

              C Offline
              C Offline
              cbhkenshin
              wrote on last edited by
              #6

              Whu dont you Right click the file and check the security tab and see if Every one is Entered And have Full Control. Just Helping if not then Have a nice day sorry to bother. -- modified at 0:31 Sunday 2nd April, 2006

              1 Reply Last reply
              0
              • T tjDieHard

                I am writing a small Wx app and need to access a file on the HDD to fill a combobox. I am using StreamReader and ReadLine to get it into the box. I have moved the file to the root, the file has no permissions set. Each time that I run the app it errors to the catch and tells me that it cannot find the file. I have tried File.Exists( file ) and it also tells me that it is not there. I have used @"c:\nex_tex.txt" and "c:\\nex_tex.txt" with no success. If I didn't see it with my own eyes I wouldn't believe that it was there. Anyway I am new to C# and obviously am missing something. Thanks in Advance DH

                M Offline
                M Offline
                mav northwind
                wrote on last edited by
                #7

                Hi! Could it be that your Windows Explorer is hiding the extensions of known filetypes so that you're seeing "nex_tex.txt" as filename but the true filename is "nex_tex.txt.txt"? Regards, mav -- Black holes are the places where god divided by 0...

                T 1 Reply Last reply
                0
                • T tjDieHard

                  I have checked all,and all is okay. If it was a permission would it error this way or would I get the access denied type error? I m lost

                  G Offline
                  G Offline
                  Guffa
                  wrote on last edited by
                  #8

                  If you don't have permission to access a file, the error message you get is that it doesn't exist. This is commonly found when someone tries to make a web application access a file in a user folder, like for an example the desktop. As the web application is not run under the user's account it can not access files in a user folder. I still think that it might be a permission problem, especially if you moved the file from some other folder. Then it might still have permission settings from the previous place. Create a new folder somewhere that you know the application has access, put the file in the folder, and in the advanced security properties of the folder choose to replace all security settings of child objects. That will remove any specific settings on the file. Now try to access the file. --- b { font-weight: normal; }

                  1 Reply Last reply
                  0
                  • M mav northwind

                    Hi! Could it be that your Windows Explorer is hiding the extensions of known filetypes so that you're seeing "nex_tex.txt" as filename but the true filename is "nex_tex.txt.txt"? Regards, mav -- Black holes are the places where god divided by 0...

                    T Offline
                    T Offline
                    tjDieHard
                    wrote on last edited by
                    #9

                    well turned out to be a corrupted file and poorly written error code on my part. re made the file and all is well thanks all DH

                    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