Solved

Verify a path ...

Posted on 1998-03-12
5
1,441 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
wordpress limitations 4 147
Web Development Tools for MVC 3 127
Swiper slider stops between pages 11 55
How to redirect all users but me properly to another page with htaccess 2 171
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…
What is Node.js? Node.js is a server side scripting language much like PHP or ASP but is used to implement the complete package of HTTP webserver and application framework. The difference is that Node.js’s execution engine is asynchronous and event…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

751 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