我用SharpZipLib后,解压的路径总是一大串,\aa\bb\cc\myfile
能不能在压缩的时候就压缩成一个文件,一解压就直接是myfile?谢谢
能不能在压缩的时候就压缩成一个文件,一解压就直接是myfile?谢谢
解决方案 »
- 急!大约每50ms发一次串口数据得到的串口数据丢很多
- 动软.net代码生成器数据列表做什么用的
- 如何用循环求出数组中元素不相同的个数
- 大家好,我想用C#写个简单的SEO小功能
- 怎样复制DataSet结构?
- C#操作ExceL的问题
- 各位大侠,大家好。
- 请问怎样将aspx页面自身关闭啊?
- ps=Process.GetProcesses(); 进程性能计数器禁用,如何打开?
- C#调用ShellExecute打开IE的问题
- 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));