all groups > vb.net upgrade > september 2003 >
You're in the

vb.net upgrade

group:

Relative path to an input file


Relative path to an input file Hogan's Goat
9/26/2003 12:48:21 AM
vb.net upgrade: I need to find out how to create a path to an input file that's relative to
where the app is running. For example, here's what I have so far:

strProfile = "C:\MyProfile.prx"

Obviously this app will break quickly if the file isn't in the root, and I
don't want to put the profile in the root anyway. Would this work?

strProfile = ".\MyProfile.prx"

Can you do that sort of relative referencinh in VB? Have mercy on me, I'm
an admitted newbie at this.

Hogan out.

--
"Politics is the entertainment branch of industry" - Frank Zappa.
Re: Relative path to an input file Paul Clement
9/26/2003 9:00:49 AM
[quoted text, click to view]

¤ I need to find out how to create a path to an input file that's relative to
¤ where the app is running. For example, here's what I have so far:
¤
¤ strProfile = "C:\MyProfile.prx"
¤
¤ Obviously this app will break quickly if the file isn't in the root, and I
¤ don't want to put the profile in the root anyway. Would this work?
¤
¤ strProfile = ".\MyProfile.prx"
¤
¤ Can you do that sort of relative referencinh in VB? Have mercy on me, I'm
¤ an admitted newbie at this.

I don't believe the File classes support relative paths. However, you can determine where the
executable is running and work from there:

Dim FileInfoPath As IO.FileInfo

FileInfoPath = New IO.FileInfo(System.Reflection.Assembly.GetExecutingAssembly.Location)


Paul ~~~ pclement@ameritech.net
Re: Relative path to an input file Herfried K. Wagner [MVP]
9/26/2003 11:55:52 AM
Hello,

"Hogan's Goat" <yeah@right.com> schrieb:
[quoted text, click to view]

Maybe you can use 'Uri.MakeRelative' (untested).

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
http://www.mvps.org/dotnet

AddThis Social Bookmark Button