62,267
社区成员
发帖
与我相关
我的任务
分享
zipoutputstream = new ZipOutputStream(File.Create(this.zipfilecreatename));
zipoutputstream.SetLevel(this.ziplevel);
Crc32 crc = new Crc32();
foreach (DictionaryEntry item in fileList)
{
fs = File.OpenRead(item.Key.ToString());
long pai = 1024 * 1024 * 1;
long forint = fs.Length / pai;
if (fs.Length % pai > 0)
{
forint = forint + 1;
}
else
{
if (fs.Length / pai == 0)
{
forint = forint + 1;
}
}
byte[] buffer = null;
char[] opt ={ '\\' };
//ZipEntry entry = new ZipEntry(item.Key.ToString().Split(opt)[item.Key.ToString().Split(opt).Length - 2] + "\\" + item.Key.ToString().Split(opt)[item.Key.ToString().Split(opt).Length - 1]);
ZipEntry entry = new ZipEntry(this.ZFolderNM + "\\" + item.Key.ToString().Split(opt)[item.Key.ToString().Split(opt).Length - 1]);
entry.DateTime = (DateTime)item.Value;
entry.Size = fs.Length;
zipoutputstream.PutNextEntry(entry);
for (int i = 1; i <= forint; i++)
{
if (pai * i < fs.Length)
{
buffer = new byte[pai];
fs.Seek(pai * (i - 1), SeekOrigin.Begin);
}
else
{
if (fs.Length < pai)
{
buffer = new byte[fs.Length];
}
else
{
buffer = new byte[fs.Length - pai * (i - 1)];
fs.Seek(pai * (i - 1), SeekOrigin.Begin);
}
}
fs.Read(buffer, 0, buffer.Length);
crc.Reset();
crc.Update(buffer);
// entry.Crc = crc.Value;
zipoutputstream.Write(buffer, 0, buffer.Length);
zipoutputstream.Flush();
}
fs.Close();
}
zipoutputstream.Finish();
zipoutputstream.Close();
zipoutputstream.Dispose();
fs.Dispose();
string upSQL = "UPDATE zip_data SET zip_status='2',mod_dt=sysdate WHERE data_id = " + this.d_ID;
oh.ExecuteSql(upSQL);
FilesList.Clear();
fileList.Clear();
oh.cnClose();
oh = null;
return zipoutputstream.IsFinished.ToString();