使用LINQ根据单独的给定扩展数组过滤SFTPFILE
我正在研究.NET Core 6解决方案。我有sftpfile ssh.net
的列表以及每个扩展名和另一个扩展名列表,即.csv。我想基于列表2的linq从列表1过滤文件。 。我确实实现了解决方案,但是它正在使用循环。 sftpfile对象具有实际文件名称,因此同情心将在
我只使用以下代码中获得文件名,但我需要lt; sftpfile>
var exceptRejectedFileNames2 = sftpFiles.Select(x => x.Name).Except(RejectedFileName.GetNames()).ToList();
filter方法如下;
public static class RejectedFileName
{
private static readonly string[] FileNames = {".", ".."};
public static string[] GetNames()
{
return FileNames;
}
}
I am working on .NET CORE 6 solution. I have list of sftpFile SSH.NET
along with each extension and another list of extensions i.e. .csv. I want to LINQ to filter files from list 1 based on list 2. i.e. if list 2 have .csv & .txt then LINQ should filter out only .csv and .txt files. I did implement solution but it is using loop. sftpFile object has property name which is actual file name so the compassion will be on that
I get the fileName only with the following code but I need list<sftpFile>
var exceptRejectedFileNames2 = sftpFiles.Select(x => x.Name).Except(RejectedFileName.GetNames()).ToList();
filter method as below;
public static class RejectedFileName
{
private static readonly string[] FileNames = {".", ".."};
public static string[] GetNames()
{
return FileNames;
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
然后在服务课上
then in service class