How to change working dir in a NT service app?

B

Berkflow

Anyone know how to change the current working directory in a windows NT
service application written in C#?
It appears to start in the windows system32 directory not where the exe is
located which really screws up my app which acts on business objects in the
directory that the exe lives and therefore doesn't find the dependencies
because I'm not GAC'ing them. (And don't say just GAC 'em cause thats
another story I can't go into here!)
Is it even possible?
 
J

John Vottero

Berkflow said:
Anyone know how to change the current working directory in a windows NT
service application written in C#?
It appears to start in the windows system32 directory not where the exe is
located which really screws up my app which acts on business objects in the
directory that the exe lives and therefore doesn't find the dependencies
because I'm not GAC'ing them. (And don't say just GAC 'em cause thats
another story I can't go into here!)
Is it even possible?

How about:

Environment.CurrentDirectory = System.AppDomain.CurrentDomain.BaseDirectory;
 
P

Peter Ericsson

Here is another way to do it.

System.IO.Directory.SetCurrentDirectory
(Application.StartupPath);
 

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