How to: Determine the Windows System Directory in Visual Basic

This example sets a string containing the path of the Windows System directory.

Note

Your computer might show different names or locations for some of the Visual Studio user interface elements in the following instructions. The Visual Studio edition that you have and the settings that you use determine these elements. For more information, see Visual Studio Settings.

Example

Dim systemDirectory As String
systemDirectory = System.Environment.SystemDirectory

This code example is also available as an IntelliSense code snippet. In the code snippet picker, it is located in Windows Operating System > System Information. For more information, see How to: Insert IntelliSense Code Snippets.

Compiling the Code

The property returns a value such as "c:\WINNT\System32".

Security

This code requires FileIOPermission.

See Also

Tasks

How to: Determine a Directory's Attributes in Visual Basic

Reference

Environment.GetFolderPath

Other Resources

File, Directory, and Drive Properties in Visual Basic