我用SharpZipLib后,解压的路径总是一大串,\aa\bb\cc\myfile
能不能在压缩的时候就压缩成一个文件,一解压就直接是myfile?谢谢
能不能在压缩的时候就压缩成一个文件,一解压就直接是myfile?谢谢
解决方案 »
- 双击主窗体datagridView某行弹出子窗体,在子窗体上对该行进行实时编辑
- winform中Math.Round的问题
- Windows服务与窗体程序交换数据问题
- 找一个有类视图及其类关系(如依赖、细化等)的C#例子,或者哪本参考书上有例子也可以。
- asp.net 中 EXCEL如何删除或隐藏 EXCEL表中 某一行
- C#怎么使用摄像头 捕获人体动作(手臂张扬,脸部检测)
- 多个窗体之间来回切换时数值之间的传递问题
- C#如何调用一个DELPHI写的dll
- 怎么学习.net
- 如何将字符串“110011”转换为二进制数?
- httpwebrequset和httpwebresponse取得网站HMTL,假死现象
- (求助)请问哪一个工具可以查看如system32.dll,netapi32.dll,api32.dll里面提供哪些方法?
public static void ZipFileMain(string[] FileToZip, string ZipedFile)
{
Crc32 crc = new Crc32();
ZipOutputStream s = new ZipOutputStream(File.Create(ZipedFile));
s.SetLevel(6); // 0 - store only to 9 - means best compression
foreach (string file in FileToZip)
{
//打开压缩文件
FileStream fs = File.OpenRead(file);
byte[] buffer = new byte[fs.Length];
fs.Read(buffer, 0, buffer.Length);
ZipEntry entry = new ZipEntry(file);
entry.DateTime = DateTime.Now;
// set Size and the crc, because the information
// about the size and crc should be stored in the header
// if it is not set it is automatically written in the footer.
// (in this case size == crc == -1 in the header)
// Some ZIP programs have problems with zip files that don't store
// the size and crc in the header.
entry.Size = fs.Length;
fs.Close();
crc.Reset();
crc.Update(buffer);
entry.Crc = crc.Value;
s.PutNextEntry(entry);
s.Write(buffer, 0, buffer.Length);
}
s.Finish();
s.Close();
}
ZipEntry entry = new ZipEntry(Path.GetFileName(file));