More info is better
- From: "Doug Sanders" <DougS@xxxxxxxxxxxxx>
- Date: Sun, 18 Sep 2005 21:13:35 -0700
Thanks for more information.
The previous answer solved most of my problem, but this explains corrective
action for the other things I can do wrong.
Thanks
Doug
"Someone" <nobody@xxxxxxx> wrote in message
news:rd3Xe.42490$ct5.13879@xxxxxxxxxxxxx
> At startup, you could execute these commands to switch the current path to
> where your App is:
>
> ChDrive App.Path
> ChDir App.Path
>
>
> It's not enough to use "ChDir App.Path", because that doesn't switch the
> current drive. It changes the path in the drive where the EXE is in, but
it
> doesn't change the drive. If your App is at "C:\MyApp\MyApp.exe", and the
> current path is "D:\", then after "ChDir App.Path", the current path is
> still "D:\".
>
> To get the current path in VB, use the following:
>
> Debug.Print CurDir
>
> In DOS(and Windows), there is a current drive, and a current path for each
> drive. The current path in the current drive is simply called the current
> path. Changing the path for the non-current drive does not change the
> current drive, so the current path stays the same.
>
> For an example, here are some commands I used in Command Prompt and their
> results(I have Windows XP and the CD is the OS CD):
>
> C:\WINDOWS>d:
> D:\>cd c:\windows\system32
> D:\>c:
> C:\WINDOWS\system32>d:
> D:\>cd i386
> D:\I386>c:
> C:\WINDOWS\system32>d:
> D:\I386>cd c:\windows
> D:\I386>c:
> C:\WINDOWS>cd c:\windows\system32
> C:\WINDOWS\system32>
>
> Finally, it's better to use a string variable instead of App.Path. If the
> user put your EXE in the root folder of C: drive, App.Path would return
> "C:\". If the user put the EXE in a subfolder, App.Path would return
> "C:\SomeFolder". There is no trailing backslash in the last one. Instead
of
> this, use the following:
>
> Public AppPath As String
>
> AppPath = App.Path
> If Right(AppPath, 1) = "\" Then
> ' Truncate the last "\"
> AppPath = Left(AppPath, Len(AppPath) - 1)
> End If
>
> When opening a file, use the following:
>
> Open AppPath & "\Somefile.txt" For Input As #f1
>
> If you have used App.Path above, and the EXE is in "C:\", the file name
> would be "C:\\Somefile.txt", which would generate a runtime error.
>
> Note that the Open statement above does not care what the current path is,
> so it's not important in this case. If your Open statement is like the
> following, then it does matter:
>
> Open "Somefile.txt" For Input As #f1
>
>
>
> "Doug Sanders" <DougS@xxxxxxxxxxxxx> wrote in message
> news:%23$gl370uFHA.3548@xxxxxxxxxxxxxxxxxxxxxxx
> >I don't do a lot of VB programming, here's the problem.
> >
> > I've developed a working project that loads documents and files on
demand.
> > These are all in my project folder on the 'C' drive.
> >
> > How do I refer to these files when all this is burned onto a CD ROM
where
> > I
> > won't know the client's CD drive letter.
> >
> > Hope I explained tis well.
> >
> > Thanks,
> >
> > Doug.
> >
> >
>
>
.
- References:
- Simple path problem - I'm embarrassed
- From: Doug Sanders
- Re: Simple path problem - I'm embarrassed
- From: Someone
- Simple path problem - I'm embarrassed
- Prev by Date: Re: Capture the Computer Desktop
- Next by Date: Re: Out of Memory Problem in VB 6.0 Application.
- Previous by thread: Re: Simple path problem - I'm embarrassed
- Next by thread: Search & Filter
- Index(es):
Relevant Pages
|