How to find path for windows folder?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How can I find path of windows folder using vb.net? It could be winnt or
windows depending upon the os.

System.Environment.SpecialFolder enumeration does not have a constant for
windows folder.
 
This might work for you:

System.Environment.GetEnvironmentVariable("windir")
 
Could you get the path for the "system" folder, then navigate one folder up?
 
Peter Rilling

How can i navigate one folder up?

Peter Rilling said:
Could you get the path for the "system" folder, then navigate one folder up?
 
By "navigate" I simply mean that once you have the path to the system
folder, you could then remove the right most folder to get the path to the
Windows folder, either by direct string manipulation of the path, or using
the Path class. This assumes that the system folder is under the Windows
folder, which I never seen it otherwise.
 
Have tried executing the internal set command in a command prompt? Does any
of the environment variables listed show the Windows folder?
 
Then get it from registry
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion | SystemRoot
 
Hi Peter

got it working as

Path.GetDirectoryName(Environment.SystemDirectory)

Thanks
 

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