|
-
Apr 19th, 2007, 03:57 PM
#1
Thread Starter
New Member
[RESOLVED] VB6 after install vb6exe, exe cannot locate file
I am using the following code to successfully access an .ini file which contains a path name, when running my vb6 application from within the directory it is installed (using an installation program):-
MsgBox ("The current App.Path before chdir is now:" & App.Path)
ChDir App.Path
MsgBox ("The current App.Path after chdir is now:" & App.Path)
pass_Path$ = "wordpathfour.txt"
Open pass_Path$ For Input As #1
'On Error GoTo File_Not_Present
Line Input #1, LineOfText$
pass_Path1$ = LineOfText$
Close #1
The problem I am having is that if I run my VB6.exe (in essence a file location gui) from the windows toolbar after installation, for all the executable appears to be looking in the correct place (from path information in the msgboxes immediatley prior to trying to open the file), error number 53 is returned, file not found ? My exe then exits.....
If I resort to running the exe from the directory again (as opposed to the programs toolbar), the file, which exists is located, and the associated form happily loads.
Why does my VB6 executable have problems opening a file when every indication that I can get is that it is looking in the right place and the file exists.... I do write to the file in question not long before trying to read it in again, is it possible that when running from the programs menu bar that I need a delay inserted to allow sufficient time for the file to close before re-reading it ?
Help....
-
Apr 19th, 2007, 04:11 PM
#2
Re: VB6 after install vb6exe, exe cannot locate file
You must always supply [complete path] + [file name] in order to open (or delete/copy/etc) file:
Code:
Open App.Path & "\" pass_Path$ For Input As #1
'or
pass_Path$ = App.Path & "\" "wordpathfour.txt"
Open pass_Path$ For Input As #1
NOTE: App.Path is your application current location.
-
Apr 20th, 2007, 02:51 AM
#3
Re: VB6 after install vb6exe, exe cannot locate file
These statement proves nothing and do nothing:
Code:
MsgBox ("The current App.Path before chdir is now:" & App.Path)
ChDir App.Path
MsgBox ("The current App.Path after chdir is now:" & App.Path)
-
Apr 20th, 2007, 02:54 AM
#4
Re: VB6 after install vb6exe, exe cannot locate file
And you should use FreeFile to get the file number not hard code #1
-
Apr 20th, 2007, 12:24 PM
#5
Thread Starter
New Member
Re: VB6 after install vb6exe, exe cannot locate file
Thanks people, thats a great help.
-
Apr 20th, 2007, 12:28 PM
#6
Re: VB6 after install vb6exe, exe cannot locate file
If you consider this resolved, would you please pull down the Thread Tools menu and click the Mark Thread Resolved menu item? That will let everyone know that you have your answer.
Thank you.
-
Apr 20th, 2007, 03:25 PM
#7
Thread Starter
New Member
Re: [RESOLVED] VB6 after install vb6exe, exe cannot locate file
Thanks for providing such a useful site.
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
|