searching for a directory. 
Author Message
 searching for a directory.

Hi.  Can someone please tell me how to check if a directory exists.  In my
program, I ask the user for a path and a filename to restore a file from.  I
got it to check if the file exists.  If it doesn't it exist, it displays an
error message. But, if the directory or drive does not exist, the program
crashes.

also...currently, I ask the user for the path and filename separatly eg.
Enter path:  a:\
Enter filename:  test.dat
I then can check if the filename variable is valid (8 characters).  Then, I
add the path and the filename together.  How can I ask the user to enter a
path and a filename at the same time (eg. Eg. Please enter a file to
restore:  a:\test\file.dat ) and then check if the filename is less than
8characters (less than 12 characters including the extention)

thanks!!!!!!!!!!

Nick



Wed, 18 Jun 1902 08:00:00 GMT  
 searching for a directory.

Quote:

>Hi.  Can someone please tell me how to check if a directory exists.

Try to open a file nul from that directory. Remember to close it also.

Osmo



Wed, 18 Jun 1902 08:00:00 GMT  
 searching for a directory.
umm.... what is a file nul ?

thanks...


Quote:


> >Hi.  Can someone please tell me how to check if a directory exists.

> Try to open a file nul from that directory. Remember to close it also.

> Osmo



Wed, 18 Jun 1902 08:00:00 GMT  
 searching for a directory.

Quote:

>umm.... what is a file nul ?

It is a device. Dos can open it from any valid directory.

Osmo



Wed, 18 Jun 1902 08:00:00 GMT  
 searching for a directory.

Quote:

>Hi.  Can someone please tell me how to check if a directory exists.  In my
>program, I ask the user for a path and a filename to restore a file from.  I
>got it to check if the file exists.  If it doesn't it exist, it displays an
>error message. But, if the directory or drive does not exist, the program
>crashes.

Are you turning off I/O checking with {$I-}...{$I+} and checking
IoResult after attempting to open the file? IMHO that would be a
better guide as to whether it is possible to open the file in that
directory, than simply checking for the existance of the directory.
IoResult will be 2 for file not found, if you're opening a file to
read it, 3 for Path Not Found and other non-0 values for other errors.

Quote:
>also...currently, I ask the user for the path and filename separatly eg.
>Enter path:  a:\
>Enter filename:  test.dat
>I then can check if the filename variable is valid (8 characters).  Then, I
>add the path and the filename together.  How can I ask the user to enter a
>path and a filename at the same time (eg. Eg. Please enter a file to
>restore:  a:\test\file.dat ) and then check if the filename is less than
>8characters (less than 12 characters including the extention)

fsplit will chop the path, file name and extension into separate
strings for you. It's in the DOS unit, and in the online help.
Quote:
>thanks!!!!!!!!!!

>Nick



Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Need : Recursive file search/directory search

2. question about using Delphi to search directories for strings of data

3. How Copy 1 Directory with Sub Directory

4. Pascal-search the web quickly with Search Spaniel

5. Pascal-search the web quickly with Search Spaniel

6. Delphi-search the web quickly with Search Spaniel

7. file and directory searching... How?

8. How do put pdxusrs.lck files in directory other than data directory ??

9. directory is busy

10. Changing the Location of the NET FILE Directory in the BDE

11. Touching directories

12. directory

 

 
Powered by phpBB® Forum Software