471,831 Members | 764 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,831 software developers and data experts.

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 21902
"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
NeoPa
reply views Thread by NeoPa | last post: by
reply views Thread by YellowAndGreen | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.