Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

check if a link has a valid path before trying to jump to that path 1

Status
Not open for further replies.

TalosBlack

Programmer
Jan 6, 2004
33
US
I want to check if a path is valid before i set my directory as that path. The reason being if i try to jump to that path i get a windows error and have to hit ok before my program finishes. I want my program to finish without prompting that a network connection is unavailable. (The reason i'm having this problem is because i am retreiving the target from a link and then jumping to it's target. However as you know links can often be out dated and there directories can be removed.) I figure the easiest way to do this is to check the validity of the path but i dno't know how to do that before trying to jump into the given path. Any help would be great.

Thanks

John
 
Code:
   const char * path="..."; 
   if( (_access( path, 0 )) != -1 )
   {
      printf( " Path exists\n" );
   }
else {
      printf(" Path do not exists\n");
}
If the path refers to a file then you can check also for read/write permissions.
-obislavu-

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top