How to get a application pathi in run time? in C#
-
Hi All, Warm New Year Greetings. Can anyone of you tell me how to get the application path during run time in C#. Please do reply. Regards Babu
If u want to get the path of your application, then use the below code: System.Reflection.Assembly.GetExecutingAssembly().Location Thanks & Regards, Venkat
-
Hi All, Warm New Year Greetings. Can anyone of you tell me how to get the application path during run time in C#. Please do reply. Regards Babu
Happy New Year to you, too! Use
Application.ExecutablePath
andApplication.StartupPath
, or use the System.Reflection namespace to get the properties of your assembly:System.Reflection.Assembly.GetExecutingAssembly.Location
SkyWalker
-
Happy New Year to you, too! Use
Application.ExecutablePath
andApplication.StartupPath
, or use the System.Reflection namespace to get the properties of your assembly:System.Reflection.Assembly.GetExecutingAssembly.Location
SkyWalker
HI.. How to get the path of the folder or file that the user has clicked in the windows explorer
Thanks & Regards, Venkat
-
Happy New Year to you, too! Use
Application.ExecutablePath
andApplication.StartupPath
, or use the System.Reflection namespace to get the properties of your assembly:System.Reflection.Assembly.GetExecutingAssembly.Location
SkyWalker
-
If u want to get the path of your application, then use the below code: System.Reflection.Assembly.GetExecutingAssembly().Location Thanks & Regards, Venkat
-
Hi All, Warm New Year Greetings. Can anyone of you tell me how to get the application path during run time in C#. Please do reply. Regards Babu
-
Thank you for your kind response.i need to get the path in console application.but in console application Application.ExecutablePath and Application.StartupPath are not working. Is there any other way. babu
Of course they are working :-) You just have to add the
System.Windows.Forms
reference, then add theusing System.Windows.Forms;
line to your Program.cs file. After that, a line of code like this one:string S = Application.ExecutablePath;
will return the information you need.SkyWalker
-
Hello, Happy new year! I think "System.Environment.CurrentDirectory" is what you need. All the best, Martin
Not quite, Martin :-) It returns the directory from which this process starts. During the running, the current directory may change. Then you need to use the
Application.ExecutablePath
.SkyWalker
-
Not quite, Martin :-) It returns the directory from which this process starts. During the running, the current directory may change. Then you need to use the
Application.ExecutablePath
.SkyWalker
Hello!
Mircea Puiu wrote:
During the running, the current directory may change
You mean the path where the exe was called changes? OK, I never took care of that. But, I mainly use "System.Environment.CurrentDirector" because of it's design time support. All the other methods I tested return an obscure design path. All the best, Martin
-
Hello!
Mircea Puiu wrote:
During the running, the current directory may change
You mean the path where the exe was called changes? OK, I never took care of that. But, I mainly use "System.Environment.CurrentDirector" because of it's design time support. All the other methods I tested return an obscure design path. All the best, Martin
No, no! The current directory is the same with the executable path when the app starts. You may change the current directory (by using a file dialog for example), and that has nothing to do with the execution path.
SkyWalker
-
No, no! The current directory is the same with the executable path when the app starts. You may change the current directory (by using a file dialog for example), and that has nothing to do with the execution path.
SkyWalker