What is the code to get the Windows directory for the local machine?
i.e. c:\WINNT or c:\Windows
Thanks!
Printable View
What is the code to get the Windows directory for the local machine?
i.e. c:\WINNT or c:\Windows
Thanks!
VB Code:
MessageBox.Show(Environment.GetFolderPath(Environment.SpecialFolder.System))
try using this property >>
system.environment.systemdirectory
Same result .;)
This gives me the C:\[Windows Dir]\System32\ directory. Is there a property that will just return me the Windows directory (without the System32)? Of course, I can parse it out, but just wondering if there is a property for it so I don't have to do the work...
Thanks again!
:)VB Code:
Declare Function GetWindowsDirectory Lib "kernel32.dll" Alias "GetWindowsDirectoryA" (ByVal lpBuffer As System.Text.StringBuilder, ByVal nSize As Integer) As Integer Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim path As New System.Text.StringBuilder(255) GetWindowsDirectory(path, path.Capacity) MessageBox.Show(path.ToString) End Sub
I'd like to do it without using API calls. If there is a .NET property handy, I'd much rather use that. Are there any .NET properties or functions available?
yes...
VB Code:
Dim path As New IO.DirectoryInfo(Environment.SystemDirectory) MessageBox.Show(path.FullName.Replace(path.Name, ""))
Great! Thanks!