Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Verify a path ...

Posted on 1998-03-12
5
Medium Priority
?
1,451 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 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

Independent Software Vendors: 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

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…
This article covers the basics of the Sass, which is a CSS extension language. You will learn about variables, mixins, and nesting.
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
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…

704 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