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. How can I check whether the folder is exist or not?

How can I check whether the folder is exist or not?

Scheduled Pinned Locked Moved C / C++ / MFC
c++question
4 Posts 4 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.
  • N Offline
    N Offline
    nachilau
    wrote on last edited by
    #1

    Hello all, I would like to know how can I check whether the folder is exist or not? Which function should I use in visual C++? and which library should I included into my program? Thanks! Nachi

    C H D 3 Replies Last reply
    0
    • N nachilau

      Hello all, I would like to know how can I check whether the folder is exist or not? Which function should I use in visual C++? and which library should I included into my program? Thanks! Nachi

      C Offline
      C Offline
      csk
      wrote on last edited by
      #2

      try using chdir function. i.e., set the current directory to the required folder. if it fails then the folder does not exist (or atlease unusable)

      1 Reply Last reply
      0
      • N nachilau

        Hello all, I would like to know how can I check whether the folder is exist or not? Which function should I use in visual C++? and which library should I included into my program? Thanks! Nachi

        H Offline
        H Offline
        Hydralisk
        wrote on last edited by
        #3

        _access() can Determine file-access permission. Return Value Each of these functions returns 0 if the file has the given mode. The function returns –1 if the named file does not exist or is not accessible in the given mode; in this case, errno is set as follows: EACCES Access denied: file’s permission setting does not allow specified access. ENOENT Filename or path not found. Thinking in difference!

        1 Reply Last reply
        0
        • N nachilau

          Hello all, I would like to know how can I check whether the folder is exist or not? Which function should I use in visual C++? and which library should I included into my program? Thanks! Nachi

          D Offline
          D Offline
          David Crow
          wrote on last edited by
          #4

          I like using _access() myself, but GetFileAttributes() is also available.

          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