Assembly.GetExecutingAssembly().

  • Thread starter Thread starter csharpula csharp
  • Start date Start date
C

csharpula csharp

Hello,
I am using Assembly.GetExecutingAssembly().Location in order to get the
path to the running executable and to attach to it continuation of path
i want to access in code.

What I get is the path + dll file with
Assembly.GetExecutingAssembly().Location ,how can I get the path to
Debug folder only without the dll? With which property?
Thank u!
 
string LogDirectory = Path.GetDirectoryName(Application.ExecutablePath);

LogDirectory += "\\Logs\\" + LogFileName;
 
Hello,
I am using Assembly.GetExecutingAssembly().Location in order to get the
path to the running executable and to attach to it continuation of path
i want to access in code.

What I get is the path + dll file with
Assembly.GetExecutingAssembly().Location ,how can I get the path to
Debug folder only without the dll? With which property?
Thank u!

*** Sent via Developersdexhttp://www.developersdex.com***

Hi,

// Your path to executable or dll
string location =
System.Reflection.Assembly.GetExecutingAssembly().Location;
MessageBox.Show(location);

// Return only folder path without dll or exe
string folder = System.IO.Path.GetDirectoryName(location);
MessageBox.Show(folder);

Thanks,

Onur Güzel
 
Good thoughts, another option to use Path.Combine to merge the string e.g.
Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "Logs"),
"fileName.txt")

Regards,
Alex
 
Back
Top