Executing directory Path?

  • Thread starter Thread starter bob
  • Start date Start date
B

bob

Hi,
I have a DLL that uses the XMLReaderSettings class say mySettings.
I want to add mySchema.xsd to mySettings.Schemas.

As far as I can make out I need an absolute path to the mySchema.xsd
file.

Being inside a DLL, the only way I could see to get this was using the
Assembly.GetAssembly().Location method.

This worked fine on the development machine but on the production
machine the call was returning the root directory.

As a kludge I put mySchema. xsd in the root directory and away we
went.

Would appreciate any thoughts on how to fix this.

thanks
Bob
 
Try..

string path =
Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

-Drew
 
Hi Drew,
thanks for your reply.
I will try this as soon as the production machine becomes available.
But it seems to me that it will still fail as GetDirectoryName is
working on what is passed back by GetExecutingAssembly.Location

The problem is that GetExecutingAssembly.Location passes back a valid
location on the development machine and the root directory on the
production machine.
I will post the result.
thanks
Bob
 
Hi Drew,
thanks for your reply.
I will try this as soon as the production machine becomes available.
But it seems to me that it will still fail as GetDirectoryName is
working on what is passed back by GetExecutingAssembly.Location

The problem is that GetExecutingAssembly.Location passes back a valid
location on the development machine and the root directory on the
production machine.
I will post the result.
thanks
Bob

this might be what you are looking for..I have not tried it myself..

Assembly.GetEntryAssembly().Location.
 
Back
Top