473,411 Members | 2,013 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,411 software developers and data experts.

Dll Path

Tim
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 ?
Dec 21 '05 #1
4 3765
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.

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Tim" <Ti*@discussions.microsoft.com> wrote in message
news:58**********************************@microsof t.com...
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 ?

Dec 21 '05 #2
Tim
Thank you, Ignacio.

"Ignacio Machin ( .NET/ C# MVP )" wrote:
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.

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Tim" <Ti*@discussions.microsoft.com> wrote in message
news:58**********************************@microsof t.com...
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 ?


Dec 22 '05 #3
Hi,

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

I am using:
string path = System.Reflection.Assembly.GetAssembly(this.GetTyp e()).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
"Ignacio Machin ( .NET/ C# MVP )" wrote:
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.

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Tim" <Ti*@discussions.microsoft.comwrote in message
news:58**********************************@microsof t.com...
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 ?


Feb 27 '07 #4
Once you get the path, invoke:

string yourDirectory = Path.GetDirectoryName(yourPathAsString);
"eieed" <ei***@discussions.microsoft.comwrote in message
news:3E**********************************@microsof t.com...
Hi,

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

I am using:
string path =
System.Reflection.Assembly.GetAssembly(this.GetTyp e()).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
"Ignacio Machin ( .NET/ C# MVP )" wrote:
>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.

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Tim" <Ti*@discussions.microsoft.comwrote in message
news:58**********************************@microso ft.com...
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 ?



Feb 27 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

31
by: John Roth | last post by:
I'm adding a thread for comments on Gerrit Holl's pre-pep, which can be found here: http://tinyurl.com/2578q Frankly, I like the idea. It's about time that all of the file and directory stuff...
9
by: Bengt dePaulis | last post by:
I have a local directory that I want to include in my sys.path How to save it permanently? Regards /Bengt
70
by: Michael Hoffman | last post by:
Many of you are familiar with Jason Orendorff's path module <http://www.jorendorff.com/articles/python/path/>, which is frequently recommended here on c.l.p. I submitted an RFE to add it to the...
34
by: Reinhold Birkenfeld | last post by:
Hi, the arguments in the previous thread were convincing enough, so I made the Path class inherit from str/unicode again. It still can be found in CVS:...
2
by: Rob Cowie | last post by:
Hi, Given a string representing the path to a file, what is the best way to get at the filename? Does the OS module provide a function to parse the path? or is it acceptable to split the string...
1
by: William Stacey [MVP] | last post by:
I need a bullet proof way to combine a root and a relative path to form a FQ rooted path (similar to a VDir in IIS). Path.Combine alone will not do the job in all cases. I also need to be sure...
4
by: python | last post by:
Bad file names, i.e. filenames the OS considers illegal, will cause functions in the os.path module to raise an error. Example: import os.path print os.path.getsize( 'c:/pytest/*.py' ) On...
34
by: Alexnb | last post by:
Gerhard Häring wrote: No, it didn't work, but it gave me some interesting feedback when I ran it in the shell. Heres what it told me: Traceback (most recent call last): File...
8
by: moondaddy | last post by:
I'm posting code for a user control ( FunctionConnectorSelector) below which has 3 content controls in it. each content control uses a style from a resource dictionary merged into the app.xaml...
6
by: bukzor | last post by:
I have to go into these convulsions to get the directory that the script is in whenever I need to use relative paths. I was wondering if you guys have a better way: from os.path import dirname,...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.