By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,333 Members | 1,389 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,333 IT Pros & Developers. It's quick & easy.

How to change working dir in a NT service app?

P: n/a
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?

Nov 13 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
"Berkflow" <sb*****@hotmail.com> wrote in message
news:Of*************@TK2MSFTNGP10.phx.gbl...
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;

Nov 13 '05 #2

P: n/a
Here is another way to do it.

System.IO.Directory.SetCurrentDirectory
(Application.StartupPath);
-----Original Message-----
Anyone know how to change the current working directory in a windows NTservice application written in C#?
It appears to start in the windows system32 directory not where the exe islocated which really screws up my app which acts on business objects in thedirectory that the exe lives and therefore doesn't find the dependenciesbecause I'm not GAC'ing them. (And don't say just GAC 'em cause thatsanother story I can't go into here!)
Is it even possible?

.

Nov 13 '05 #3

P: n/a
Thanks John - That worked perfectly!

"John Vottero" <Jo**@mvpsi.com> wrote in message
news:ek**************@TK2MSFTNGP12.phx.gbl...
"Berkflow" <sb*****@hotmail.com> wrote in message
news:Of*************@TK2MSFTNGP10.phx.gbl...
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;

Nov 13 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.