How to: Determine the Windows System Directory
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here. ArchiveDisclaimer

How to: Determine the Windows System Directory in Visual Basic

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

NoteNote:

  The options available in dialog boxes, and the names and locations of menu commands you see, might differ from what is described in Help, depending on your active settings or edition. This Help page was written with General Development Settings in mind. To change your settings, choose Import and Export Settings on the Tools menu. For more information, see Visual Studio Settings.

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 Snippets Into Your Code (Visual Basic).

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

This code requires FileIOPermission Class.

Show:
© 2016 Microsoft