Verify a path ...

How to verify if a path is a valid path (a path that exist) ?
LVL 1
AlexanderAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
dabblerConnect With a Mentor Commented:
All of those functions will work for either a file *or* a directory.  Just call them with the full path of the directory.  E.g., to see if path "C:\\Bamboo\\Slivers" exists, call FindFirstFile ("C:\\Bamboo\\Slivers", &wfd) and see if it returns a valid handle.  Then close the handle.
0
 
dabblerCommented:
1) Call OpenFile (.., .., OF_EXIST)
2) Call FindFirstFile (.., &a_win32finddata_struct)
   // don't forget to call FindClose () on the returned handle,
   // if it's not INVALID_HANDLE_VALUE
2) Call GetShortPathName (...)
0
 
AlexanderAuthor Commented:
Sorry but i dont want to check if a file exist in a path but only if the path exist. If one of those functions do that can you be more explicit ?
Thank you !
0
 
AlexanderAuthor Commented:
ok, thank you, but finally i've used the SetCurrentDirectory function, because i need to change too, if the directory exist !


0
 
kevinkwirthCommented:
Isn't this better?

                    System.IO.DirectoryInfo di = new System.IO.DirectoryInfo(stringPath);

                    bValidFile = di.Exists;
0
All Courses

From novice to tech pro — start learning today.