Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: VB7
Expertise: Intermediate
Jun 15, 2002

Retrieve Windows and System directories

In VB.NET you don't need to call the GetWindowsDirectory and GetSystemDirectory API functions to retrieve the path the Windows and System directories. Retrieving the System directory is as simple as calling the Environment.SystemDirectory property:

Dim sysDir As String = Environment.SystemDirectory()
The Environment class doesn't expose any property that returns the Windows directory; however, it is simple to extract the first portion of the system directory's path, by using the GetDirectoryName method of the System.IO.Path class:

Dim winDir As String = System.IO.Path.GetDirectoryName _
    (Environment.SystemDirectory)
Alternatively, you can retrieve the Windows directory by reading the WINDIR environment variable:

winDir = Environment.GetEnvironmentVariable("WINDIR")
Francesco Balena
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date