Solved

Verify a path ...

Posted on 1998-03-12
5
1,431 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 70 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to I "stripe" columns using XSLT 3 46
PHP radio buttons with email not sending 24 99
PHP PDO get the error if exists 3 88
ColdFusion Rereplace 3 78
Preface This article introduces an authentication and authorization system for a website.  It is understood by the author and the project contributors that there is no such thing as a "one size fits all" system.  That being said, there is a certa…
Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
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…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

776 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