Problem opening file

  • Thread starter Thread starter Eric Caron
  • Start date Start date
E

Eric Caron

Hi

Here's my problem, I create a windows service with Config.xml file.
All setup for my service is in this file. I create a windows
application to manage these settings (Config.XML File). This work good
if the two applications are in the same folder and Config.XML is in
the folder too but If not, my windows application setting don't work.
In my windows form I have a Service controler components to manage my
service (start, stop, ...). With this component I can manage service
anywhere on a network using MachineName property. Is it possible to
use this same property to manage my Config.XML file ?

If my service run on computer 1 and I lauch my configuration
application on computer 2, I can manage (start, stop, ...) service on
computer 1 but I also want to manage Config.XML file on computer 1

Thanks
 
Salut Eric. ;-)

I don't know if that's the answer to your point, but... at
least "my two cents" (been facing this problem too).

Once your app is set up as a service, you must place your
config.xml file under /System32/ folder .

Hope this helps.


olivier aka Cypher.
 
Instead of placing the config file in the System32 folder, you could change
the working directory of the service (at service startup (first instruction
in OnStart() method)

Process pc = Process.GetCurrentProcess();
Directory.SetCurrentDirectory
(pc.MainModule.FileName.Substring(0,pc.MainModule.FileName.LastIndexOf(@"\")
));

In this way, you can place the .exe.config file in the same directory as the
exe file.

José
 
Back
Top