By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,686 Members | 1,510 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,686 IT Pros & Developers. It's quick & easy.

How to get Windows Directory?

P: n/a
Hi,
is there a better way to get the Windows directory?
I manage to get the system directory with :
System.Environment.SystemDirectory

So I was wondering how do I get the Windows directory?

Nov 20 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Hi,

Trace.WriteLine(Environment.GetEnvironmentVariable ("WINDIR"))

Ken

---------------

"Shelby" <sh****@itsupport.com.sg> wrote in message
news:uQ*************@TK2MSFTNGP10.phx.gbl...
Hi,
is there a better way to get the Windows directory?
I manage to get the system directory with :
System.Environment.SystemDirectory

So I was wondering how do I get the Windows directory?

Nov 20 '05 #2

P: n/a
* "Shelby" <sh****@itsupport.com.sg> scripsit:
So I was wondering how do I get the Windows directory?


System directory:

'Environment.GetFolderPath(Environment.SpecialFold er.System))'

Windows directory:

'System.Environment.ExpandEnvironmentVariables("%W inDir%")'

- or -

Trick by Bill McCarthy:

'System.Environment.GetFolderPath(CType(&H24, System.Environment.SpecialFolder))'

- or -

P/invoke on 'GetWindowsDirectory' (IMO the preferred way):

<URL:http://groups.google.de/groups?selm=%23pJhic2CBHA.2200%40tkmsftngp07>

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #3

P: n/a
Hi,

thanks for that.
By the way, can I get IIS root folder with that too?
"Shelby" <sh****@itsupport.com.sg> wrote in message
news:uQ*************@TK2MSFTNGP10.phx.gbl...
Hi,
is there a better way to get the Windows directory?
I manage to get the system directory with :
System.Environment.SystemDirectory

So I was wondering how do I get the Windows directory?

Nov 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.