Checking the Existence of a File 
Author Message
 Checking the Existence of a File

Not trying to be difficult or anything...

Shouldn't a code segment perform one (and only one) logical program
segment?  That is, if you have a listimage control you wish to
populate programmatically, do you do everything to populate it in the
same Sub? Or, do you split up each logical segment into smaller
subsegments using Subs and Functions promoting greater code reuse?

Also, who's to say that you want to do anything with the file?

Or, say that the file is an Access database, and before doing the
OpenDatabase thinger, you want to check to see if it's there?

In addition, you can specify attributes (vbNormal, vbHidden, vbSystem,
vbVolume, vbDirectory) to preclude the possibility of checking for the
wrong file system element.

Anyway, as I said (and you included in your post) before, most of
these thingers are in regards to checking for the existence of a file.

Yeah, you can attempt to open a file and trap the error if it doesn't
exist, but I have a personal preference to avoid errors rather than
handling them.  

Probably because I'm REALLY lazy. :)



Quote:

>> I've seen quite a few articles/e-mails/tips regarding checking the existence
>> of a file by attempting to open it and trapping an error if it does not exist.

>> What's wrong with using the dir$ function (as follows)??

>Permissions on a network or NTFS volume might not let you
>actually open the file. There could be a directory with the same
>name. Due to multitasking, the file could appear or disappear
>between the execution of your function and the Open, so you have
>to trap for all the same errors anyway. Why bother with a
>separate check for the file's existence?



Tue, 24 Oct 2000 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. How to check for existence of a file on harddisk form OL VBscript

2. Checking for existence of a file???

3. Check for existence of a file?

4. Checking for existence of a file...

5. A2K Check for Existence of Back End File

6. Checking for the existence of a file

7. Check File Existence?

8. Checking for the Existence of a File

9. Checking for random file existence in Visual Basic

10. Check for the existence of a file.

11. Newbie Question: File existence checking

12. file existence check

 

 
Powered by phpBB® Forum Software