2011-08-18 126 views
2

我使用下面進入路徑「我的文檔」文件夾在Windows 7中,並通過其目錄遍歷:與Environment.GetFolderPath(Environment.SpecialFolder.Personal)意外目錄

Dim diri As New DirectoryInfo(Environment.GetFolderPath(Environment.SpecialFolder.Personal)) 
For Each diri In diri.GetDirectories 
MessageBox.Show(diri.Name) 
Next 

其中一個消息框我得到的是一個'我的音樂'文件夾。我的'我的文檔'文件夾中沒有該文件夾。

這是預期的行爲?

回答

3

是的。在名爲「我的音樂」的「文檔」文件夾中有一個鏈接到您的「音樂」文件夾的隱藏鏈接。 「圖片」和「視頻」類似。這些用於向後兼容與生產力差的Windows XP軟件,這些軟件將路徑硬編碼到這些文件夾,而不是像使用系統定義的設置一樣。

要查看所有這些鏈接,請在命令提示符下,鍵入:

Dir /AL %UserProfile%\Documents 
0

使用的下方即可非隱藏的目錄

Dim diri As New DirectoryInfo(Environment.GetFolderPath(Environment.SpecialFolder.Personal)) 
For Each diri In diri.GetDirectories 
If(dir.Attributes = FileAttributes.Directory) Then 
    MessageBox.Show(diri.Name) 
End If 
Next