我有個問題。我試圖找出我的 .zip 檔案是否為空。問題是測驗長度不起作用,因為 zip 檔案的大小永遠不等于 0。
FileInfo[] fileInfos = ...
foreach (FileInfo fileInfo in fileInfos)
{
if (fileInfo.Length < 0)
{
// do action like delete
}
}
預先感謝您的幫助
uj5u.com熱心網友回復:
您可以使用ZipArchive功能:
using System.IO.Compression;
using (ZipArchive archive = ZipFile.Open(zipPath, ZipArchiveMode.Read))
{
int fileCount = archive.Entries.Count;
bool isEmpty = fileCount == 0;
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/372180.html
