How to change working dir in a NT service app?

  • Thread starter Thread starter Berkflow
  • Start date Start date
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?
 
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;
 
Here is another way to do it.

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