Getting Special Folders Path - Visual Basic .NET

Tags: VB.NET, VB 2008, VB 2010, VB 2012, VB 2013

This is a tutorial on how to get special folders path such as desktop, documents, etc.. in Visual Basic .NET

Get Desktop Path in Visual Basic .NET

To get the desktop path and show it in a message box:

Dim DesktopPath As String = CreateObject("WScript.Shell").Specialfolders(10)
'OR
Dim DesktopPath As String = System.Environment.GetFolderPath(Environment.SpecialFolder.Desktop)
MsgBox(DesktopPath)

Get Documents Path in Visual Basic .NET

To get the Documents path and show it in a message box:

Dim DocumentsPath As String = CreateObject("WScript.Shell").Specialfolders(16)
'OR
Dim DocumentsPath As String = System.Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)
MsgBox(DocumentsPath)

Get My Music Path in Visual Basic .NET

To get the Music path and show it in a message box:

Dim MusicPath As String = System.Environment.GetFolderPath(Environment.SpecialFolder.MyMusic)
MsgBox(MusicPath)

Get My Pictures Path in Visual Basic .NET

To get the Pictures path and show it in a message box:

Dim PicturesPath As String = System.Environment.GetFolderPath(Environment.SpecialFolder.MyPictures)
MsgBox(PicturesPath)

Get My Videos Path in Visual Basic .NET

To get the Videos path and show it in a message box:

Dim VideosPath As String = System.Environment.GetFolderPath(Environment.SpecialFolder.MyVideos)
MsgBox(VideosPath)

Get Favorites Path in Visual Basic .NET

To get the Favorits path and show it in a message box:

Dim FavoritesPath As String = CreateObject("WScript.Shell").Specialfolders(15)
MsgBox(FavoritesPath)

Get Fonts Path in Visual Basic .NET

To get the Fonts path and show it in a message box:

Dim FontsPath As String = CreateObject("WScript.Shell").Specialfolders(8)
MsgBox(FontsPath)


Share This

Home | About | Contact | Privacy Policy

Copyright visual-basic-tutorials.com 2017 - All Rights Reserved.