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 / C++ / MFC
  4. Looking for a file

Looking for a file

Scheduled Pinned Locked Moved C / C++ / MFC
question
9 Posts 6 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.
  • H Offline
    H Offline
    Halawlaws
    wrote on last edited by
    #1

    Hi how can i look for a file if it exists without using fopen /\|-||\/|/\|)

    B J M R T 5 Replies Last reply
    0
    • H Halawlaws

      Hi how can i look for a file if it exists without using fopen /\|-||\/|/\|)

      B Offline
      B Offline
      BlackDice
      wrote on last edited by
      #2

      here's a function that I put in one of my programs to make sure a folder existed, but you could also use it for a file.

      BOOL FolderExists(CString strFolderName)
      {   
      	return GetFileAttributes(strFolderName) != INVALID_FILE_ATTRIBUTES;   
      }
      

      My articles www.stillwaterexpress.com BlackDice

      H 1 Reply Last reply
      0
      • H Halawlaws

        Hi how can i look for a file if it exists without using fopen /\|-||\/|/\|)

        J Offline
        J Offline
        Jose Lamas Rios
        wrote on last edited by
        #3

        Try this:

        bool fileExists(LPCTSTR filepath)
        {
          return (_taccess(filepath, 00) == 0);
        }

        Hope that helps, -- jlr http://jlamas.blogspot.com/[^]

        H 1 Reply Last reply
        0
        • H Halawlaws

          Hi how can i look for a file if it exists without using fopen /\|-||\/|/\|)

          M Offline
          M Offline
          Marc Soleda
          wrote on last edited by
          #4

          Another way: WIN32_FIND_DATA wfd; HANDLE hFind = FindFirstFile(csFilePath, &wfd); if (hFind != INVALID_HANDLE_VALUE) // File exists ... Marc Soleda. ... she said you are the perfect stranger she said baby let's keep it like this... Tunnel of Love, Dire Straits.

          H 1 Reply Last reply
          0
          • M Marc Soleda

            Another way: WIN32_FIND_DATA wfd; HANDLE hFind = FindFirstFile(csFilePath, &wfd); if (hFind != INVALID_HANDLE_VALUE) // File exists ... Marc Soleda. ... she said you are the perfect stranger she said baby let's keep it like this... Tunnel of Love, Dire Straits.

            H Offline
            H Offline
            Halawlaws
            wrote on last edited by
            #5

            k thx man /\|-||\/|/\|)

            1 Reply Last reply
            0
            • J Jose Lamas Rios

              Try this:

              bool fileExists(LPCTSTR filepath)
              {
                return (_taccess(filepath, 00) == 0);
              }

              Hope that helps, -- jlr http://jlamas.blogspot.com/[^]

              H Offline
              H Offline
              Halawlaws
              wrote on last edited by
              #6

              thx /\|-||\/|/\|)

              1 Reply Last reply
              0
              • B BlackDice

                here's a function that I put in one of my programs to make sure a folder existed, but you could also use it for a file.

                BOOL FolderExists(CString strFolderName)
                {   
                	return GetFileAttributes(strFolderName) != INVALID_FILE_ATTRIBUTES;   
                }
                

                My articles www.stillwaterexpress.com BlackDice

                H Offline
                H Offline
                Halawlaws
                wrote on last edited by
                #7

                thx man /\|-||\/|/\|)

                1 Reply Last reply
                0
                • H Halawlaws

                  Hi how can i look for a file if it exists without using fopen /\|-||\/|/\|)

                  R Offline
                  R Offline
                  Roland Pibinger
                  wrote on last edited by
                  #8

                  Try one of the stat functions, e.g.

                  int stat (const char *path, struct _stat *buffer);

                  1 Reply Last reply
                  0
                  • H Halawlaws

                    Hi how can i look for a file if it exists without using fopen /\|-||\/|/\|)

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

                    PathFileExists can help tooo :)

                    "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

                    cheers, Alok Gupta VC Forum Q&A :- I/ IV

                    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