我有一個ZipArchive
,它有一堆文件。我正在嘗試獲取所有文件格式爲.stl
的文件,但我似乎無法正確使用它。嘗試使用linq將包含.stl的文件添加到列表中
以下是我有:
var scan = import.ZipFile.Entries.Any(e => e.Name == string.Format("*.stl").ToList());
我相信,我失去了一些東西愚蠢,但我不斷收到錯誤:
operator '==' cannot be applied to operands of type 'string' and
'system.collections.generic.list<char>'
會有人能幫助我嗎?
你放錯了'()'。它應該是:'var scan = import.ZipFile.Entries.Any(e => e.Name == string.Format(「*。stl」))。ToList();',但是你會得到一個'List '回來,你可能需要'Where'。你的比較也不行。你需要比較擴展名,使用'Path.GetExtension'方法。 –
Habib
2015-02-05 15:44:41