473,396 Members | 2,055 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

How do you determine Windows directory

Is there a method in the .NET Framework that returns the path to just the
Windows directory?

The closest I've been able to find is System.Environment.SystemDirectory.
On my machine, it returns "C:\Windows\System32". What I'm looking for in
this case is "C:\Windows".

TIA,

Richard Rosenheim
Nov 21 '05 #1
3 1701
Hi there... You can get what you want like this...

Aproach 1
********
MsgBox(System.Environment.GetEnvironmentVariable(" Windir"))

Aproach 2
********
Dim winfolder As String =
CType(System.Environment.GetFolderPath(Environment .SpecialFolder.System).Split("\"),
String())(0) + "\" +
CType(System.Environment.GetFolderPath(Environment .SpecialFolder.System).Split("\"),
String())(1)

MsgBox(winfolder)

Regards,
--
Angel J. Hernández M.
MCP - MCAD - MCSD - MCDBA
http://groups.msn.com/desarrolladoresmiranda
http://ajhsis.net
"Richard L Rosenheim" <ri*****@rlr.com> escribió en el mensaje
news:OQ**************@tk2msftngp13.phx.gbl...
Is there a method in the .NET Framework that returns the path to just the
Windows directory?

The closest I've been able to find is System.Environment.SystemDirectory.
On my machine, it returns "C:\Windows\System32". What I'm looking for in
this case is "C:\Windows".

TIA,

Richard Rosenheim

Nov 21 '05 #2
"Richard L Rosenheim" <ri*****@rlr.com> schrieb:
Is there a method in the .NET Framework that returns the path to just the
Windows directory?


Windows directory:

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

- or -

Trick by Bill McCarthy:

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

- or -

P/invoke on 'GetWindowsDirectory':

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

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #3
Thanks everyone -- the first approach is what I was looking for. Completely
forgot about the environment variables...

Richard Rosenheim
"Angel J. Hernández M." <an**********@hotmail.com> wrote in message
news:e7**************@TK2MSFTNGP11.phx.gbl...
Hi there... You can get what you want like this...

Aproach 1
********
MsgBox(System.Environment.GetEnvironmentVariable(" Windir"))

Aproach 2
********
Dim winfolder As String =
CType(System.Environment.GetFolderPath(Environment .SpecialFolder.System).Spl
it("\"), String())(0) + "\" +
CType(System.Environment.GetFolderPath(Environment .SpecialFolder.System).Spl
it("\"), String())(1)

MsgBox(winfolder)

Regards,
--
Angel J. Hernández M.
MCP - MCAD - MCSD - MCDBA
http://groups.msn.com/desarrolladoresmiranda
http://ajhsis.net
"Richard L Rosenheim" <ri*****@rlr.com> escribió en el mensaje
news:OQ**************@tk2msftngp13.phx.gbl...
Is there a method in the .NET Framework that returns the path to just the Windows directory?

The closest I've been able to find is System.Environment.SystemDirectory. On my machine, it returns "C:\Windows\System32". What I'm looking for in this case is "C:\Windows".

TIA,

Richard Rosenheim


Nov 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: lucpustjens | last post by:
Hello, I want te determine the client operating system, because I need to kno the default cookie directory. If there is a way to determine the cooki directory directly, than it is also good. ...
0
by: Buddy Ackerman | last post by:
I need to programatically determine the directory that the application/service is running from. If I use Environment.CurrentDirectory it returns the System32 directory. Is there anyway to get this...
3
by: Web Webon | last post by:
Hi everybody! I wonder if this is possible? I need to determine if a client is using "windows classic folders" or anything else. If I instantiate a Shell ActiveX object is there a way of...
6
by: dawn | last post by:
Hi, How can I determine the directory from which my app is started. Since upon installation the user can decide in which directory to install the file...I want to be able to load a file from a...
0
by: marfi95 | last post by:
Basically, I keep the state of some objects serialized in an xml file through the use of a data set. The xml file serialized is persisted onto a shared network drive. However, the file is only...
3
by: KSC | last post by:
Hello, Is there a way to programmatically determine if a directory is shared and if so, what the sharename is? It seems a simple question, but I have been searching and not found the...
12
by: garyusenet | last post by:
I want to write a program that lists all folders on my local hard drive in order of size, any ideas for how I might do this? Thankyou, Gary.
1
by: topramen | last post by:
does any one here know of a good way to to determine whether or not a given path is a directory (e.g., "c:\mydir") or a file (e.g., "c:\mydir \myfile.txt")? i started attacking this problem by...
9
by: Scott | last post by:
What is the most reliable method to determine the folder a script is running in? I was looking at the globals in $_SERVER but all the variables also listed the actual file the script was running...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.