471,317 Members | 1,907 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

WHat is the Directory?

GTi
I have created a "DLL LIB" in c# that I use in several ".EXE" projects.
But I need to know where this DLL fil is located on disk from inside my
DLL,
NOT where the EXE file is located.

What function must I use to get the directory of the DLL file ?

Dec 22 '05 #1
5 1113
GTi wrote:
I have created a "DLL LIB" in c# that I use in several ".EXE" projects.
But I need to know where this DLL fil is located on disk from inside my
DLL,
NOT where the EXE file is located.

What function must I use to get the directory of the DLL file ?

Inside you dll, do the following:

string location = typeof(AClassInYourDll).Assembly.Location

HTH,
Andy
--
To email me directly, please remove the *NO*SPAM* parts below:
*NO*SPAM*xmen40@*NO*SPAM*gmx.net
Dec 22 '05 #2
Hi,

function must I use to get the directory of the DLL file ?

Inside you dll, do the following:

string location = typeof(AClassInYourDll).Assembly.Location


You can do Assembly.GetExecutingAssembly().Location , in this case you do
not need a type
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
Dec 22 '05 #3
GTi
Tx all, you saved my xmas !

Dec 23 '05 #4
GTi

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

function must I use to get the directory of the DLL file ?

Inside you dll, do the following:

string location = typeof(AClassInYourDll).Assembly.Location


You can do Assembly.GetExecutingAssembly().Location , in this case you do
not need a type
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation


Hmm... still have problem using this...

Assembly.GetExecutingAssembly().Location

Does NOT return the correct path to my dll directory.

When running on a ASP.NET server it reurns:
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temp orary ASP.NET
Files\Development\80fad5dd\dd8b6fcb\assembly\dl3\a 16593d5\7f90b94c_6f0ac601\MyLIB.DLL

Not in my case:
c:\development\web\bin\

Any other ideas?

Dec 26 '05 #5
GTi
My development project is a ASP.NET, NT Service Agent and a Windows
Application running on the same machine.

They all need to read the same configuration file/data like database
connection string, some settings etc. And some utillity files is also
puttet on that diretcory.

The dll/exe files must be on the same directory on the computer. So
putting a config file on that directory "must be the solution".
But ASP.NET don't give me this directory at all.
Any solution of this problem.

Dec 29 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

26 posts views Thread by Lasse Edsvik | last post: by
2 posts views Thread by =?Utf-8?B?RGF2aWQgVGhpZWxlbg==?= | last post: by
1 post views Thread by amygrant1701 | last post: by
13 posts views Thread by Fro | last post: by
reply views Thread by rosydwin | last post: by

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.