469,353 Members | 2,121 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,353 developers. It's quick & easy.

How to change working dir in a NT service app?

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
3 21789
"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
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
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.

Similar topics

6 posts views Thread by Chakkaradeep | last post: by
22 posts views Thread by Bob and Sharon Hiller | last post: by
3 posts views Thread by =?Utf-8?B?QXhlbCBEYWhtZW4=?= | last post: by
2 posts views Thread by =?Utf-8?B?bXVyYWRqYW1lcw==?= | last post: by
4 posts views Thread by Peter | last post: by
reply views Thread by zhoujie | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.