Click here to Skip to main content
15,915,094 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how to used app path in vb.net?
but app path is not working in vb.net.
what to do?
Posted
Comments
OriginalGriff 18-Apr-12 6:49am    
This is not a good question - we cannot work out from that little what you are trying to do.
Remember that we can't see your screen, access your HDD, or read your mind.
Use the "Improve question" widget to edit your question and provide better information.

The best method is probably this:
C#
string exeFilePath = System.Reflection.Assembly.GetEntryAssembly().Location;
string exeDirectory = System.IO.Path.GetDirectoryName(exeFilePath);


If founds the location of the main executable model of the entry assembly of the application (where you entry point is, usually the method Main), regardless of the assembly where this code is called.

Note, there are many solutions of this problems, but many of them are not so good. For example, Application.StartupPath requires System.Windows.Forms, other methods depend on how application is hosted (for example, may not work correctly for a Windows Service application or under debugger), but the method I've demonstrated always work correctly.

—SA
 
Share this answer
 
Comments
VJ Reddy 22-Apr-12 22:30pm    
Good answer with a broader perspective. 5!
Sergey Alexandrovich Kryukov 22-Apr-12 22:37pm    
Thank you, VJ.
--SA
[no name] 23-Apr-12 0:27am    
Descriptive answer. My 5+ :)
Sergey Alexandrovich Kryukov 23-Apr-12 0:46am    
Thank you, Maulik.
--SA
Try this
You will have to use
VB
System.AppDomain.CurrentDomain.BaseDirectory()

instead of
VB
App.Path
 
Share this answer
 
If your requirement is to obtain the folder from where the application has started then I think Application.StartupPath property may be useful as explained here
http://msdn.microsoft.com/en-us/library/system.windows.forms.application.startuppath.aspx#Y0[^]
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 22-Apr-12 21:58pm    
I'm voting 4. Formally, it resolves the problem, but this one is by far not the best one. Please see my solutions and the notes.
--SA
VJ Reddy 22-Apr-12 22:32pm    
Thank you, SA.
Seen your answer. It is robust solution.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900