Vb.net 如何选择扩展名为.ppt的所有文件并将其设置为字符串列表?

Vb.net 如何选择扩展名为.ppt的所有文件并将其设置为字符串列表?,vb.net,Vb.net,我的问题是如何选择目录中的所有.ppt文件,然后将其设置为如下字符串: For Each foundFile As String In My.Computer.FileSystem.GetFiles(My.Computer.FileSystem.SpecialDirectories.MyDocuments, Microsoft.VisualBasic.FileIO.SearchOption.SearchTopLevelOnly, "*.ppt") Next strFileToCopy

我的问题是如何选择目录中的所有.ppt文件,然后将其设置为如下字符串:

For Each foundFile As String In My.Computer.FileSystem.GetFiles(My.Computer.FileSystem.SpecialDirectories.MyDocuments, Microsoft.VisualBasic.FileIO.SearchOption.SearchTopLevelOnly, "*.ppt")
    Next

strFileToCopy = (foundFile)
Dim listOfPPTs As List(Of String) = New List(Of String)
For Each foundFile As String In My.Computer.FileSystem.GetFiles(My.Computer.FileSystem.SpecialDirectories.MyDocuments, Microsoft.VisualBasic.FileIO.SearchOption.SearchTopLevelOnly, "*.ppt")
    listOfPPTs.Add(foundFile)
Next
但是它会出错。 我怎样才能解决这个问题?
对不起,我的英语不好。

据我所知,您的代码的目的是什么,我建议您这样做:

For Each foundFile As String In My.Computer.FileSystem.GetFiles(My.Computer.FileSystem.SpecialDirectories.MyDocuments, Microsoft.VisualBasic.FileIO.SearchOption.SearchTopLevelOnly, "*.ppt")
    Next

strFileToCopy = (foundFile)
Dim listOfPPTs As List(Of String) = New List(Of String)
For Each foundFile As String In My.Computer.FileSystem.GetFiles(My.Computer.FileSystem.SpecialDirectories.MyDocuments, Microsoft.VisualBasic.FileIO.SearchOption.SearchTopLevelOnly, "*.ppt")
    listOfPPTs.Add(foundFile)
Next
您将在中有一个.ppt文件列表

listOfPPTs
在此列表中,您可以对列表中的每个条目执行操作,如:

For Each aFile As String In listOfPPTs
  encryptFile(aFile)
Next
子加密文件的代码我将留给您


你好,保罗

有什么不对吗?另外,在您的示例中,您正在搜索rtfoh抱歉,我正在搜索ppt文件
make as a list of String
mean store in a
list(of String)
尝试进行足够的解释以克服语言障碍我的意思是我想加密我的所有.ppt文件是的,你需要花更多的时间研究和仔细解释你在玩什么。