Dll Path

G

Guest

Hi,

How can I find the path in which a dll is executing from? I do not want
the Exe path. Is there a way to get the dll path in C# - something like the
output of GetModuleFileName API ?
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,

Arey ou talking about a .net assembly ?
If so you can use Assembly.Location , all you need to do is get a reference
to the assembly you are interested in.
 
G

Guest

Thank you, Ignacio.

Ignacio Machin ( .NET/ C# MVP ) said:
Hi,

Arey ou talking about a .net assembly ?
If so you can use Assembly.Location , all you need to do is get a reference
to the assembly you are interested in.
 
G

Guest

Hi,

I'm also trying to get the path a DLL is located.

I am using:
string path = System.Reflection.Assembly.GetAssembly(this.GetType()).Location;

This give path a value of:
C:\Program Files\Microsoft Dynamics\GP\AddIns\Workflow.dll

Which is great, but I don't want the "Workflow.dll" part of the path.

Is there a different call I can use to bring back just:
C:\Program Files\Microsoft Dynamics\GP\AddIns\

Or is there a way I can strip out the "Workflow.dll" part of the path
without hard-coding the DLL name.

Thanks,
Ed
 
F

Fred Mellender

Once you get the path, invoke:

string yourDirectory = Path.GetDirectoryName(yourPathAsString);
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top