Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Verify a path ...

Posted on 1998-03-12
5
Medium Priority
?
1,458 Views
Last Modified: 2013-12-26
How to verify if a path is a valid path (a path that exist) ?
0
Comment
Question by:Alexander
  • 2
  • 2
5 Comments
 
LVL 1

Expert Comment

by:dabbler
ID: 1299585
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
 
LVL 1

Author Comment

by:Alexander
ID: 1299586
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
 
LVL 1

Accepted Solution

by:
dabbler earned 280 total points
ID: 1299587
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
 
LVL 1

Author Comment

by:Alexander
ID: 1299588
ok, thank you, but finally i've used the SetCurrentDirectory function, because i need to change too, if the directory exist !


0
 

Expert Comment

by:kevinkwirth
ID: 23423009
Isn't this better?

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

                    bValidFile = di.Exists;
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
JavaScript has plenty of pieces of code people often just copy/paste from somewhere but never quite fully understand. Self-Executing functions are just one good example that I'll try to demystify here.
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
Suggested Courses

971 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question