这个错误是由于无法将类型'System.Collections.Generic.List<System.IO.FileInfo>' 隐式转换为'System.Collections.Generic.List' 引起的。

原因是 GetFiles() 方法返回的是一个 FileInfo 类型的列表,而你将其放入了一个 List 类型的变量中。

要解决这个问题,你可以在 Select() 方法中将 FileInfo 对象转换为文件路径字符串,例如:

List toBeDownloadedFiles = folderInfos.GetFiles('.', SearchOption.AllDirectories) .Select(file => file.FullName) .OrderBy(file => file) .ToList();

C# 错误 CS0029: 无法将类型“System.Collections.Generic.List<System.IO.FileInfo>”隐式转换为“System.Collections.Generic.List<string>”

原文地址: https://www.cveoy.top/t/topic/fPk 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录