C# 筛选特定文件类型 (mp3 和 mp4) 的代码示例
在 C# 中,您可以使用 Where 方法来筛选只包含特定文件类型的文件列表。例如,如果您想要只扫描 .mp3 和 .mp4 文件,您可以修改以下代码:
List<string> toBeDownloadedFiles = folderInfos.GetFiles("*.*", SearchOption.AllDirectories)
.Where(file => file.Extension == '.mp3' || file.Extension == '.mp4')
.Select(file => file.FullName)
.OrderBy(file => file)
.ToList();
这将只选择文件扩展名为 '.mp3' 或 '.mp4' 的文件进行处理。
原文地址: https://www.cveoy.top/t/topic/eNE 著作权归作者所有。请勿转载和采集!