Executing directory Path?

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
 
D

DrewCE

Try..

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

-Drew
 
B

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
 
P

parez

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.
 

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