using System.IO;
using ICSharpCode.SharpZipLib.Checksums;
using ICSharpCode.SharpZipLib.Zip;
using ICSharpCode.SharpZipLib.GZip;我写了一个函数
public static void ZipPath(string []FileList,string createZipFile)
{
string[] filenames =FileList;
Crc32 crc = new Crc32();
ZipOutputStream s = new ZipOutputStream(File.Create(createZipFile));
s.SetLevel(6);
foreach (string file in filenames)
{
FileStream fs = File.OpenRead(file);
//UTF8Encoding temp = new UTF8Encoding(true); byte[] buffer = new byte[fs.Length];
fs.Read(buffer, 0, buffer.Length);
ZipEntry entry = new ZipEntry(file);
entry.DateTime = DateTime.Now;
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();
}高手来了吗?
using ICSharpCode.SharpZipLib.Checksums;
using ICSharpCode.SharpZipLib.Zip;
using ICSharpCode.SharpZipLib.GZip;我写了一个函数
public static void ZipPath(string []FileList,string createZipFile)
{
string[] filenames =FileList;
Crc32 crc = new Crc32();
ZipOutputStream s = new ZipOutputStream(File.Create(createZipFile));
s.SetLevel(6);
foreach (string file in filenames)
{
FileStream fs = File.OpenRead(file);
//UTF8Encoding temp = new UTF8Encoding(true); byte[] buffer = new byte[fs.Length];
fs.Read(buffer, 0, buffer.Length);
ZipEntry entry = new ZipEntry(file);
entry.DateTime = DateTime.Now;
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();
}高手来了吗?
[email protected]
修改源代码ZipConstants.cs:
namespace ICSharpCode.SharpZipLib.Zip
{
/// <summary>
/// This class contains constants used for zip.
/// </summary>
public sealed class ZipConstants
{…… public static string ConvertToString(byte[] data)
{
return Encoding.GetEncoding("gb2312").GetString(data, 0, data.Length);
// return Encoding.ASCII.GetString(data,0, data.Length);
}
public static byte[] ConvertToArray(string str)
{
return Encoding.Convert(Encoding.Unicode, Encoding.GetEncoding("gb2312"),
Encoding.Unicode.GetBytes(str));
// return Encoding.ASCII.GetBytes(str);
}