16,554
社区成员
发帖
与我相关
我的任务
分享
Dim filelist As New List(Of String)
Dim a As System.Collections.ObjectModel.ReadOnlyCollection(Of String) = My.Computer.FileSystem.GetFiles("C:\", FileIO.SearchOption.SearchAllSubDirectories)
For Each b As String In a
If My.Computer.FileSystem.GetFileInfo(b).Extension.ToLower = "txt" Then
If My.Computer.FileSystem.GetFileInfo(b).Name.Substring(0, 2).ToLower = "dd" Then
filelist.Add(b)
End If
End If
Next
try
{
DirectoryInfo dir = new System.IO.DirectoryInfo(@"C:\");
List<FileInfo> list = new List<FileInfo>();//要得到的文件列表
foreach(System.IO.FileInfo f in dir.GetFiles)
{
if (f.Extension.ToLower() == "txt")
{
if (f.FullName.Replace("C:\\", "").Substring(0, 2).ToLower() == "dd")
{
list.Add(f);
}
}
}
}
catch(Exception e)
{
}