|
|
Title | Get the paths to special folders in VB.NET |
Description | This example shows how to get the paths to special folders in VB.NET. It uses the Environment.GetFolderPath method to get the folders' locations. |
Keywords | path, special folders, VB.NET |
Categories | Windows, VB.NET, Files and Directories |
|
|
When it starts, the program calls the ListFolder subroutine for each of the values defined by the System.Environment.SpecialFolder enumerated type.
Subroutine ListFolder displays the SpecialFolder value as a string and then passes it to Environment.GetFolderPath to get the location of the special folder.
|
|
Private Sub Form1_Load(ByVal sender As System.Object, ByVal _
e As System.EventArgs) Handles MyBase.Load
ListFolder(Environment.SpecialFolder.ApplicationData)
ListFolder(Environment.SpecialFolder.CommonApplicationData)
...
ListFolder(Environment.SpecialFolder.Templates)
txtFolders.Select(0, 0)
End Sub
Private Sub ListFolder(ByVal folder_type As _
System.Environment.SpecialFolder)
Dim txt As String = folder_type.ToString & ":"
txtFolders.Text &= String.Format("{0,-25}", txt) & _
Environment.GetFolderPath(folder_type) & vbCrLf
End Sub
|
|
|
|
|
|