FSO 返回不存在的子文件夹 [英] FSO returns non-existing subfolders
问题描述
我正在使用此代码获取目录的子文件夹:
I'm using this code to get the subfolders of a directory:
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\Eigene Bilder".Eigene Bilder"是 Windows 在德语中称为我的图片"文件夹.
Now when m_sFolder is "C:\Users\MyUser\Documents", one subfolder is "C:\Users\MyUser\Documents\Eigene Bilder". "Eigene Bilder" is what Windows calls the folder "My Pictures" in German language.
但是,文件夹C:\Users\MyUser\Documents"不包含My Pictures"、Pictures"或Eigene Bilder".
However, the folder "C:\Users\MyUser\Documents" doesn't contain either "My Pictures", "Pictures" or "Eigene Bilder".
可以在此处找到文件夹我的图片":C:\用户\我的用户\图片
The folder "My Pictures" is to be found here: C:\Users\MyUser\Pictures
谁能告诉我为什么 FSO 可能要告诉我这个目录C:\Users\MyUser\Documents\Eigene Bilder"存在?
Can anybody tell me why FSO might want to tell me that this directory "C:\Users\MyUser\Documents\Eigene Bilder" exists?
我完全不知所措.
推荐答案
这不是目录,而是 连接(或重新解析)点,类似于重定向到文件系统级别的另一个位置.
It's not a Directory it's a Junction (or Reparse) Point which is like a redirection to another location at the filesystem level.
dir "C:\Users\MyUser\Documents\" /ad
从命令行将使用
标签(而不是
)列出这些.
From the command line will list these with a <JUNCTION>
tag (as opposed to <DIR>
).
不需要使用 FSO,内置的文件系统函数将不包括这些:
There is no need to use the FSO, the built in filesystem functions will not include these:
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
这篇关于FSO 返回不存在的子文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!