How to get the "Windows" directory?

  • Thread starter Thread starter parsifal
  • Start date Start date
P

parsifal

Hi,

I'm wondering how you can use the standard C# library to get the
"windows" directory? (e.g. "c:/windows"). I need to specify the
location of a config file in a service, and I don't want to hard-code
anything.

Thanks.
 
"System.Environment.SystemDirectory" returns the fully qualified path
of the system directory (In my case C:\Winnt\system32).

Hope it can help you
 
parsifal said:
Hi,

I'm wondering how you can use the standard C# library to get the
"windows" directory? (e.g. "c:/windows"). I need to specify the
location of a config file in a service, and I don't want to hard-code
anything.

Thanks.

Environment.GetEnvironmentVariable("windir");

Note that a config file should not reside in the windows directory either,
it should reside in the same directory as your service .exe.

Willy.
 
Thanks! That should work well!

Thanks for the lightning-quick reply!
 
Oh okay, so I can just do relative paths? Sounds fine to me.

Where should services be stored?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top