|
-
Dec 22nd, 2003, 02:55 PM
#1
Thread Starter
Lively Member
How to get Windows directory path?
What is the code to get the Windows directory for the local machine?
i.e. c:\WINNT or c:\Windows
Thanks!
-
Dec 22nd, 2003, 03:21 PM
#2
Sleep mode
VB Code:
MessageBox.Show(Environment.GetFolderPath(Environment.SpecialFolder.System))
-
Dec 22nd, 2003, 03:26 PM
#3
Addicted Member
try using this property >>
system.environment.systemdirectory
-
Dec 22nd, 2003, 03:31 PM
#4
-
Dec 22nd, 2003, 03:43 PM
#5
Thread Starter
Lively Member
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!
-
Dec 22nd, 2003, 03:58 PM
#6
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
~
if a post is resolved, please mark it as [Resolved]
protected string get_Signature(){return Censored;}
[vbcode][php] please use code tags when posting any code [/php][/vbcode]
-
Dec 22nd, 2003, 04:05 PM
#7
Thread Starter
Lively Member
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?
-
Dec 22nd, 2003, 04:10 PM
#8
yes...
VB Code:
Dim path As New IO.DirectoryInfo(Environment.SystemDirectory)
MessageBox.Show(path.FullName.Replace(path.Name, ""))
~
if a post is resolved, please mark it as [Resolved]
protected string get_Signature(){return Censored;}
[vbcode][php] please use code tags when posting any code [/php][/vbcode]
-
Dec 22nd, 2003, 04:21 PM
#9
Thread Starter
Lively Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|