我需要将这种类型的列表转换为字符串列表:
var fileName = (new DirectoryInfo(filePath)).GetFiles(".", SearchOption.AllDirectories).Where(a => Regex.IsMatch(a.Name, "^[^*]*" + logSelected + ".jpg$")).ToList();
有人知道吗?
请您参考如下方法:
var fileName = (new DirectoryInfo(filePath))
.GetFiles(".", SearchOption.AllDirectories)
.Where(a => Regex.IsMatch(a.Name, "^[^*]*" + logSelected + ".jpg$"))
.Select(a => a.Name)
.ToList();
或者在 Select 方法中为您需要的属性更改 a.Name。
