|
-
Oct 30th, 2009, 05:52 AM
#1
Thread Starter
Hyperactive Member
[RESOLVED] How to check if a named file exists on a machine
I want my program to start by checking that a number of files, of known location and extension type(s) is present on the PC before going on to run the app. These files will be the associated dependency files, plus certain others which previous instances of the program may have generated. Their extensions could be anything, including .dll, .ocx., .exe, .txt, .doc etc.
If a listed file is not present, I will use a message box to inform the user. My thought is to incorporate this code at the form load event. The message(s) will prompt the user to load the necessary files.
The following code seems to work so far. It requires placing a rich text box on the form (which can be small, and non-visible) and trying to load the desired file into it. If the file is not present, the On Error process brings up the Message Box :-
Dim PATH as String
PATH = "C:\Windows\System\abcde.xyz"
On Error GoTo Line10
RichTextBox1.LoadFile PATH, rtfText
GoTo Line20
Line10: MsgBox "FILE OPEN ERROR. CHECK PATH " & PATH
Line20:
(progam then continues to check for next file etc. etc. ........)
Is there please a more elegant way to achieve this, and one which will work with absolutely any extension type? I have not yet found an extension type which the above code does not deal with, but maybe there will be a few?
camoore
Wales, UK
Last edited by camoore; Oct 30th, 2009 at 05:56 AM.
Reason: missed out " " at second line of code
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|