471,325 Members | 1,591 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

How to get the "Windows" directory?

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.

Dec 14 '05 #1
4 14412
"System.Environment.SystemDirectory" returns the fully qualified path
of the system directory (In my case C:\Winnt\system32).

Hope it can help you

Dec 14 '05 #2

"parsifal" <se*************@gmail.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
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.
Dec 14 '05 #3
Thanks! That should work well!

Thanks for the lightning-quick reply!

Dec 14 '05 #4
Oh okay, so I can just do relative paths? Sounds fine to me.

Where should services be stored?

Dec 14 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by Paul Rubin | last post: by
2 posts views Thread by unknown | last post: by
2 posts views Thread by Visual Systems AB \(Martin Arvidsson\) | last post: by
1 post views Thread by inungh | last post: by
reply views Thread by rosydwin | 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.