使用vb.net在我的文档中搜索文件
我无法访问其他特殊文件夹,如我的音乐,请帮助我,我需要将所有子文件夹包含在我的文档中使用vb.net在我的文档中搜索文件,vb.net,Vb.net,我无法访问其他特殊文件夹,如我的音乐,请帮助我,我需要将所有子文件夹包含在我的文档中 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click For Each foundFile As String In My.Computer.FileSystem.GetFiles(My.Computer.FileSystem.SpecialD
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
For Each foundFile As String In My.Computer.FileSystem.GetFiles(My.Computer.FileSystem.SpecialDirectories.MyDocuments, FileIO.SearchOption.SearchAllSubDirectories, "*.txt")
ListBox1.Items.Add(foundFile)
Next
End Sub
试试这个
Dim MyDoc As New IO.FileInfo(My.Computer.FileSystem.SpecialDirectories.MyDocuments)
For Each foundFile As String In My.Computer.FileSystem.GetFiles(MyDoc.Directory.FullName, FileIO.SearchOption.SearchAllSubDirectories, "*.txt")
ListBox1.Items.Add(foundFile)
Next
将该值与一起使用以访问“我的音乐”文件夹。thx以获得回复。:)当我使用它时,它将只包括“我的音乐”文件夹。另一个文件夹呢?我需要包括我的文档中的每个文件夹。如果你看Cody Gray给你的链接,SpecialFolder的枚举之一是MyDocuments(即Environment.SpecialFolder.MyDocuments)。