|
-
Oct 6th, 2008, 05:48 AM
#1
Thread Starter
Hyperactive Member
[2005] App.Path
whats the best way to get the famous App.path in vb6 using vb.net 2005?i currently use this :
Dim sRet As String = ""
Try
sRet = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase )
sRet = sRet.ToLower
If sRet.StartsWith("file:\") Then sRet = sRet.Substring(6)
Catch ex As Exception
Debug.Fail(ex.TargetSite.Name & vbNewLine & ex.Message)
End Try
Nobody is smarter than all of us!
-
Oct 6th, 2008, 06:05 AM
#2
Junior Member
Re: [2005] App.Path
You want to get application's path?
Code:
Application.ExecutablePath
Teme64 @ windevblog.blogspot.com
-
Oct 6th, 2008, 06:20 AM
#3
Member
Re: [2005] App.Path
You can use the 'Application.StartupPath', to get Application StartupPath Property.
For example, to get the Application Directory Path:
vb Code:
Dim ApPath As String = Application.StartupPath
Dim Binpos As Integer
Binpos = InStr(ApPath.ToUpper, "BIN")
If Binpos <> 0 Then ApPath = Mid(ApPath, 1, Binpos - 1)
The 'Application.StartupPath' gives the "BIN" directory inside the Application directory.
-
Oct 6th, 2008, 06:46 AM
#4
Re: [2005] App.Path
Just note that the Application class is a member of the System.Windows.Forms namespace, so if you're doing this in a Console app you'll have to stick with what you had originally.
-
Oct 6th, 2008, 10:24 AM
#5
Re: [2005] App.Path
For console apps, couldn't he use Environment.CurrentDirectory?
That is the very essence of human beings and our very unique capability to perform complex reasoning and actually use our perception to further our understanding of things. We like to solve problems. -Kleinma
Does your code in post #46 look like my code in #45? No, it doesn't. Therefore, wrong is how it looks. - jmcilhinney
-
Oct 6th, 2008, 11:31 AM
#6
Re: [2005] App.Path
Use My.Application.Info.DirectoryPath for console application.
Let us have faith that right makes might, and in that faith, let us, to the end, dare to do our duty as we understand it.
- Abraham Lincoln -
-
Oct 6th, 2008, 06:31 PM
#7
Re: [2005] App.Path
 Originally Posted by stanav
Use My.Application.Info.DirectoryPath for console application.
Cool. I thought that that was only available for Windows apps too but, as the documentation says, it's available for all but specifically Web projects.
-
Oct 7th, 2008, 06:46 AM
#8
Thread Starter
Hyperactive Member
Re: [2005] App.Path
thanx 4 all ur contributions
Nobody is smarter than all of us!
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
|