WHat is the Directory?

  • Thread starter Thread starter GTi
  • Start date Start date
G

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 ?
 
GTi said:
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
 
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 said:
Hi,



You can do Assembly.GetExecutingAssembly().Location , in this case you do
not need a type

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\Temporary ASP.NET
Files\Development\80fad5dd\dd8b6fcb\assembly\dl3\a16593d5\7f90b94c_6f0ac601\MyLIB.DLL

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

Any other ideas?
 
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.
 
Back
Top