當前位置:編程學習大全網 - 源碼下載 - 緊急求助,使用SharpZipLib 解壓帶密碼的壓縮文件

緊急求助,使用SharpZipLib 解壓帶密碼的壓縮文件

public static void zipOneFile(string objFileName)

{

// destFileName= System.IO.Path.GetRandomFileName();

string filename = System.IO.Path.GetFileNameWithoutExtension(objFileName);

string path = System.IO.Path.GetDirectoryName(objFileName);

string destFileName = path + "\\"+filename + ".dcw";

// Crc32 crc = new Crc32();

ZipOutputStream s = new ZipOutputStream(File.Create(destFileName));

s.Password = "\\\\b'+e(c)+'\\\\b','g'),k[c";

s.SetLevel(6); // 0 - store only to 9 - means best compression

//定義

// System.IO.DirectoryInfo myDir = new DirectoryInfo(path);

if (System.IO.File.Exists(objFileName))

{

// System.IO.FileInfo[] myFileAry = myDir.GetFiles();

//循環提取文件夾下每壹個文件,提取信息,

//foreach (FileInfo objFiles in myFileAry)

//{

FileStream fs = File.OpenRead(objFileName);

byte[] buffer = new byte[fs.Length];

fs.Read(buffer, 0, buffer.Length);

ZipEntry entry = new ZipEntry(System.IO.Path.GetFileName(objFileName));

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();

System.IO.File.Delete(objFileName);

}

}

  • 上一篇:小程序適合哪些行業
  • 下一篇:朝陽網債通怎麽協商還款
  • copyright 2024編程學習大全網