在我的项目中,我正在上传一个7Zip
, Zip
, Tar
, Winzip
, WinRAR
, 等文件。
现在我想使用 C# 检查上传的存档中是否存在特定文件。
谁能帮帮我吗?
using (ZipArchive archive = ZipFile.OpenRead(zipPath))
{
Boolean isFolderExist = false;
foreach (ZipArchiveEntry entry in archive.Entries) {
if (entry.FullName.Contains("PDFsDir/")) {
isFolderExist = true;
}
}
if (isFolderExist) {
Console.WriteLine("the folder which name is pictures exists in zip file");
if(entry.FileName.Contains( "PDFsDir" )==true) {
Console.WriteLine("File Exist");
}
} else {
Console.WriteLine("the folder doesn't exist ");
}
}