精易论坛
标题:
C# Zip压缩Class.cs
[打印本页]
作者:
stillness
时间:
2012-11-23 19:36
标题:
C# Zip压缩Class.cs
1.png
(14.33 KB, 下载次数: 0)
下载附件
2012-11-23 19:35 上传
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Linq;
using System.Text;
using System.IO;
using System.Runtime.InteropServices;
namespace ClassLibrary1
{
public class zip压缩Class
{
[DllImport("zip.dll", EntryPoint = "MyZip_AddFile")]
private static extern int MyZip_AddFile(string a, string b);
public bool 压缩文件(string 待压缩文件路径, string 目标文件路径)
{
int d = MyZip_AddFile(待压缩文件路径, 目标文件路径);
if (d > 0)
{
return true;
}
else
{
return false;
}
}
// zip 压缩文件
[DllImport("zip.dll", EntryPoint = "MyZip_AddDirectory")]
private static extern int MyZip_AddDirectory(string a, string b);
public bool 压缩目录(string 待压缩目录路径, string 目录输出路径)
{
int d = MyZip_AddDirectory(待压缩目录路径, 目录输出路径);
if (d > 0)
{
return true;
}
else
{
return false;
}
}
// zip 压缩目录
[DllImport("zip.dll", EntryPoint = "MyZip_ExtractFileAll")]
private static extern int MyZip_ExtractFileAll(string a, string b);
public bool 解压文件(string 压缩文件, string 文件输出路径)
{
int t = MyZip_ExtractFileAll(压缩文件, 文件输出路径);
if (t > 0)
{
return true;
}
else
{
return false;
}
}
// zip 解压文件
[DllImport("zip.dll", EntryPoint = "MyZip_GetLastError")]
private static extern int MyZip_GetLastError();
public bool 获取错误信息()
{
int d=MyZip_GetLastError()
if(d>0)
{
return false;
}
else
{
return true;
}
}
// zip 获取错误信息
}
}
复制代码
Zip压缩Class.rar
(668 Bytes, 下载次数: 3)
2012-11-23 19:36 上传
点击文件名下载附件
下载积分: 精币 -2 枚
欢迎光临 精易论坛 (https://125.confly.eu.org/)
Powered by Discuz! X3.4