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. access to path

access to path

Scheduled Pinned Locked Moved C / C++ / MFC
questionhelp
3 Posts 3 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.
  • M Offline
    M Offline
    meirav
    wrote on last edited by
    #1

    How can i know that a certain path is valid??? In a browse button the user select a path and i want to know if it is a valid path. i tried to use _access(char* path ,in mode) but i have a problem with it: 1) I don't know what the mode should be 2) When no path was selected (char* ="") the functoin return -1 meaning i's not valid and i don't want that. Thanks

    J D 2 Replies Last reply
    0
    • M meirav

      How can i know that a certain path is valid??? In a browse button the user select a path and i want to know if it is a valid path. i tried to use _access(char* path ,in mode) but i have a problem with it: 1) I don't know what the mode should be 2) When no path was selected (char* ="") the functoin return -1 meaning i's not valid and i don't want that. Thanks

      J Offline
      J Offline
      Joe Moldovan
      wrote on last edited by
      #2

      I use the Shell Lightweight Utility APIs for this kind of stuff. You need to include "Shlwapi.h" and build with "Shlwapi.lib". The API is very easy to use. For your question, BOOL PathFileExists( LPCTSTR pszPath ); You can find this in MSDN->Platform SDK->User Interface Services->Windows Shell-> Shell Reference->Shell Lightweight Utility APIs Hope this helps!

      1 Reply Last reply
      0
      • M meirav

        How can i know that a certain path is valid??? In a browse button the user select a path and i want to know if it is a valid path. i tried to use _access(char* path ,in mode) but i have a problem with it: 1) I don't know what the mode should be 2) When no path was selected (char* ="") the functoin return -1 meaning i's not valid and i don't want that. Thanks

        D Offline
        D Offline
        Derek Waters
        wrote on last edited by
        #3

        The other alternative is the API function GetFileAttributes(), which, despite it's name, works with directories as well. It returns -1 if the file/directory does not exist. So:

        if (GetFileAttributes(path) == -1)
        {
        AfxMessageBox(_T("Invalid Path!"));
        }
        else
        {
        // Do stuff...
        }

        Hope this helps. ------------------------ Derek Waters derek@lj-oz.com

        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