Vb6 FSO返回不存在的子文件夹

Vb6 FSO返回不存在的子文件夹,vb6,fso,Vb6,Fso,我正在使用以下代码获取目录的子文件夹: Dim fo As Scripting.Folder Set fo = fso.GetFolder(m_sFolder) Dim nSubfolder As Scripting.Folder For Each nSubfolder In fo.SubFolders Debug.Print "Folder " & fo.Path & " has subfolder " & nSubfolder Next 现在,当m

我正在使用以下代码获取目录的子文件夹:

Dim fo As Scripting.Folder
Set fo = fso.GetFolder(m_sFolder)

Dim nSubfolder As Scripting.Folder

For Each nSubfolder In fo.SubFolders

    Debug.Print "Folder " & fo.Path & " has subfolder " & nSubfolder 

Next
现在,当m_sFolder为“C:\Users\MyUser\Documents”时,一个子文件夹为“C:\Users\MyUser\Documents\eGene Bilder”。 “Egene Bilder”是Windows用德语称之为“我的图片”的文件夹

但是,文件夹“C:\Users\MyUser\Documents”既不包含“我的图片”、“图片”也不包含“Egene Bilder”

“我的图片”文件夹可在此处找到: C:\Users\MyUser\Pictures

有人能告诉我为什么FSO可能想告诉我这个目录“C:\Users\MyUser\Documents\Egene Bilder”存在吗


我完全困惑了。

它不是一个目录,而是一个类似于重定向到文件系统级别的另一个位置的目录

dir "C:\Users\MyUser\Documents\" /ad
从命令行中,将使用
标记列出这些代码(与
相反)

无需使用FSO,内置文件系统功能将不包括以下内容:

Dim path As String: path = "C:\Users\MyUser\Documents\"
Dim dirn As String

dirn = Dir$(path, vbDirectory)

Do While dirn <> ""
    If (GetAttr(path & dirn) And vbDirectory) = vbDirectory And dirn <> "." And dirn <> ".." Then
        Debug.Print path & dirn
    End If
    dirn = Dir$()
Loop
Dim路径为字符串:path=“C:\Users\MyUser\Documents\”
作为字符串的Dim dirn
dirn=Dir$(路径,vbDirectory)
“边做边做”
如果(GetAttr(path&dirn)和vbDirectory)=vbDirectory和dirn“。和dirn“。那么
Debug.Print路径和目录
如果结束
dirn=Dir$()
环

如果你坚持使用FSO,你需要意识到这些事情。此示例试图了解,并应为您提供处理此问题所需的信息:

Const ssfPERSONAL = 5
Const FILE_ATTRIBUTE_REPARSE_POINT = &H400&
Dim TargetFolderPath As String
Dim SubFolder As Scripting.Folder
Dim SubFile As Scripting.File

'Don't early-bind to Shell32 objects, Microsoft has failed
'to maintain binary compatibility across Windows versions:
TargetFolderPath = CreateObject("Shell.Application").NameSpace(ssfPERSONAL).Self.Path
Debug.Print TargetFolderPath
With New Scripting.FileSystemObject
    With .GetFolder(TargetFolderPath)
        For Each SubFolder In .SubFolders
            With SubFolder
                Debug.Print .Name;
                Debug.Print " ["; .Type;
                If .Attributes And FILE_ATTRIBUTE_REPARSE_POINT Then
                    Debug.Print ", reparse point";
                End If
                Debug.Print "]"
            End With
        Next
        For Each SubFile In .Files
            With SubFile
                Debug.Print .Name; " ["; .Type; "]"
            End With
        Next
    End With
End With

谢谢您的条件不满足,但这些奇怪的文件夹具有.Attributes=1046,而所有其他文件夹具有.Attributes=16。你能告诉我需要检查哪个属性而不是“If.Attributes And FILE\u attribute\u repasse\u POINT Then”吗?谢谢。呃,
FILE\u ATTRIBUTE\u resparse\u POINT
1046
,所以我不知道还能告诉你什么。我不知道为什么不能满足这个条件。您不能正确地测试它。您的
16
被称为
FILE\u ATTRIBUTE\u目录
。我上面给出的代码非常适合我。