我使用下面的代码搜索.zip
'private void button1_Click(object sender, EventArgs e)
{
listView1.Items.Clear();
listView1.Refresh();
string[] filePaths = Directory.GetFiles(@textBox1.Text, "*.zip");
string txtSearch = textBox2.Text;
foreach (var filePath in filePaths)
{
using (ZipArchive archive = ZipFile.OpenRead(filePath))
{
foreach (ZipArchiveEntry entry in archive.Entries)
{
var position = entry.Name.IndexOf(txtSearch, StringComparison.InvariantCultureIgnoreCase);
if (position > -1)
{
listView1.Items.Add(entry.Name);
}
else
{
MessageBox.Show("FILE NOT FOUND", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}
}'
如果我想在同一时间搜索.zip和.rar,请如何解决这个问题。提前致谢。