How to get the path for "My Documents"?

Throughout Windows there are now a large number of 'special' folders such as `My Documents`. Unfortunately, the location of these important folders can vary, so we need to use the System.Enviroment to accurately find them. This code shows you how.

Dim strMyDoc As String
strMyDoc = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal).ToString()


First, we use the System.Environment.SpecialFolder to tell the system which special folder that we need.
System.Environment.SpecialFolder.Personal is represent the 'My Documents';

p.s. you also can find other special folder by change the value in SpecialFolder :

System.Environment.SpecialFolder.MyComputer
System.Environment.SpecialFolder.MyMusic
System.Environment.SpecialFolder.MyPictures

Use the GetFolderPath method of the System.Environment class to retrieve this information.

0 comments: