Get Executable Path With the Assembly Class in C#GetEntryAssembly() function is used to get the assembly of the currently executing code. We can get the path of the currently executing code with the Assembly. GetEntryAssembly(). Location property which returns the executable path of the current in a string variable.
FileName = "dcm2jpg.exe"; startInfo. WindowStyle = ProcessWindowStyle. Hidden; startInfo. Arguments = "-f j -o \"" + ex1 + "\" -z 1.0 -s y " + ex2; try { // Start the process with the info we specified. // Call WaitForExit and then the using statement will close.
C# Path filename and extensionThe Path. GetFileName returns the file name and extension of a file path represented by a read-only character span. The Path. GetFileNameWithoutExtension returns the file name without the extension of a file path represented by a read-only character span.
System.Reflection.Assembly.GetEntryAssembly().Location;
In addition:
AppDomain.CurrentDomain.BaseDirectory
Assembly.GetEntryAssembly().Location
In a Windows Forms project:
For the full path (filename included): string exePath = Application.ExecutablePath;
For the path only: string appPath = Application.StartupPath;
in visualstudio 2008 you could use this code :
var _assembly = System.Reflection.Assembly
.GetExecutingAssembly().GetName().CodeBase;
var _path = System.IO.Path.GetDirectoryName(_assembly) ;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With