Apr 18, 2009 Just a quick 'Thank You' as this answered my question/solved my problem. However, to provide a bit further info, in VB.NET 2002 at least (net 1.1) I found that Application.ExecutablePath was not useful, as it had not only the path, but included the executable file name as well, which I would have had to strip, however, the other suggestion: Application.StartupPath worked perfectly. The code snippet in this article demonstrates how to use Application class static properties to get Windows Forms application startup path, executable path and user data path using VB.NET.
-->
I would like to get the path to the execution directory of a Windows Forms application. (That is, the directory in which the executable is located.) Does anyone know of a built-in method in.NET t.
Definition
Gets the path for the executable file that started the application, not including the executable name.
Property Value
The path for the executable file that started the application.
This path will be different depending on whether the Windows Forms application is deployed using ClickOnce. ClickOnce applications are stored in a per-user application cache in the C:Documents and Settingsusername directory. For more information, see Accessing Local and Remote Data in ClickOnce Applications.
Examples
The following code example gets this property and displays its value in a text box. The example requires that
textBox1 has been placed on a form.
Visual Basic .net App PathSecurity
FileIOPermission
for getting the path. Associated enumeration: FileIOPermissionAccess Applies to
Active5 months ago
How can I get the absolute path of program I'm running?
Martin Prikryl
103k2727 gold badges216216 silver badges456456 bronze badges
LindaLinda
7 Answers
For that you can use the
Application object.
![]()
Startup path, just the folder, use Application.StartupPath() Canon creative software free download 2012.
Full .exe path, including the program.exe name on the end:, use Application.ExecutablePath()
Nick Craver♦Nick Craver
552k117117 gold badges12211221 silver badges11181118 bronze badges
Try this:
My.Application.Info.DirectoryPath [MSDN]
This is using the
My feature of VB.NET. This particular property is available for all non-web project types, since .NET Framework 2.0, including Console Apps as you require.
As long as you trust Microsoft to continue to keep this working correctly for all the above project types, this is simpler to use than accessing the other 'more direct' solutions.
Mark Hurd
Vb.net Application Folder PathMark Hurd
9,0041010 gold badges5656 silver badges8989 bronze badges
For a console application you can use
System.Reflection.Assembly.GetExecutingAssembly().Location as long as the call is made within the code of the console app itself, if you call this from within another dll or plugin this will return the location of that DLL and not the executable.
lee-mlee-m
KHALIDKHALID
Uwe Keim
28.4k3333 gold badges142142 silver badges228228 bronze badges
Eddy JawedEddy Jawed
Net Application Form 2018
Set Your Own application Path
Dim myPathsValues As String
Wajid Ali KhanWajid Ali Khan
Corey BCorey B
Not the answer you're looking for? Browse other questions tagged .netvb.net or ask your own question.Comments are closed.
|
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |