does anyone know how to return the application path, like app.path in vb6?
Printable View
does anyone know how to return the application path, like app.path in vb6?
Thanks fer thuh reply.
Application.ExecutablePath gives the path including the EXE name.
Application.StartupPath gives the path to the Dir :-)
...and in what manner does this differs to my response?Quote:
Originally posted by zchoyt
Application.ExecutablePath gives the path including the EXE name.
Application.StartupPath gives the path to the Dir :-)
Chill out!!
I just read it quickly.
I was just trying ro be helpful
Oh I'm very relaxed :)Quote:
Originally posted by zchoyt
Chill out!!
I just read it quickly.
I was just trying ro be helpful
I was just confused about your answer since it was exactly what I already posted.
I was simply wondering if my reply was unclear in some way.
np :)
The proper replacement for app.path in VB.NET is System.Reflection.Assembly.GetExecutingAssembly.Location()
(This will return the File Name of your exe at the end)
Code:Dim sPath As String
sPath = System.Reflection.Assembly.GetExecutingAssembly.Location()
I use this to find the folder:
Code:
Dim oPath As System.IO.Path
Dim sPath As String
sPath = System.Reflection.Assembly.GetExecutingAssembly.Location()
sPath = oPath.GetDirectoryName(sPath)
Well that' great and all, but I am using asp, not asp.net :)
What does that have to do with anything? :confused:Quote:
Originally posted by zchoyt
Well that' great and all, but I am using asp, not asp.net :)
What makes that the "proper" replacement for app.path? Especially if it includes the EXE name and app.path omits it? I would venture to say that Application.StartupPath does the exact same thing as app.path did, and is therefore far more "proper" than what you gave.Quote:
Originally posted by Dmyze
The proper replacement for app.path in VB.NET is System.Reflection.Assembly.GetExecutingAssembly.Location()
(This will return the File Name of your exe at the end)
http://msdn.microsoft.com/library/de...albasicnet.asp
"The App object in Visual Basic 6.0 was a global object used to set or retrieve information about the application. There is no direct equivalent for the App object in Visual Basic .NET; however, most of the properties can be mapped to equivalent properties in the .NET Framework."
"Path = System.Reflection.Assembly.GetExecutingAssembly.Location "
The Application.StartupPath is part of the System.windows.forms namespace. This is fine if you are writing a windows application in VB, however if you try to create a console application you won't have that name space available.
System.Windows.Forms.Application.StartupPath()
Not by default, but all you have to do is add a reference to it, and it is available. And you'll still be writting a normal console app. It's not too hard.Quote:
Originally posted by Dmyze
The Application.StartupPath is part of the System.windows.forms namespace. This is fine if you are writing a windows application in VB, however if you try to create a console application you won't have that name space available.
As for your quote, I would agree that it (that reflection one) is a valid replacement, which is all that quote seems to imply. But I wouldn't call it "the proper way", or even the "best way".