压缩解压缩文件和文件夹(三)
来源:互联网 发布:淘宝运营团队如何收费 编辑:程序博客网 时间:2024/06/05 17:47
// 续 压缩解压缩文件和文件夹(二)
// 下面是使用该类:
// 使用VC6.0,创建单对话框工程,命名为Testzip
// 在对话框的实现文件中加上面的类的头文件引入:#include "include/zipimplement.h"
// 在对话框上添加2个按钮:IDC_BTNZIP,IDC_BTNUNZIP,分别为压缩和解压的按钮,然后添加but事件。在其实现中添加如:
// m_strDirPath为成员变量,我是为了在其他程序地方使用而定义的,这个也可以定位临时变量。
void CTestzipDlg::OnBtnzip()
{
// TODO: Add your control notification handler code here
CString m_strDirPath= "";
GetModuleFileName(NULL, m_strDirPath.GetBufferSetLength(MAX_PATH+1), MAX_PATH);
m_strDirPath.ReleaseBuffer();
int nPos = m_strDirPath.ReverseFind('\\');
m_strDirPath = m_strDirPath.Left(nPos);
// 工作路径下测试--压缩: 删除bin目录下src.zip、zip.zip
CZipImplement czip;
CString pFilePath = m_strDirPath+"\\src";
CString mZipFileFullPath = m_strDirPath+"\\src.zip";
pFilePath.Replace("\\", "/");
mZipFileFullPath.Replace("\\", "/");
czip.ZipPackFiles(pFilePath, mZipFileFullPath, true); // 文件夹
pFilePath = m_strDirPath+"\\zip.h";
mZipFileFullPath = m_strDirPath+"\\zip.zip";
pFilePath.Replace("\\", "/");
mZipFileFullPath.Replace("\\", "/");
czip.ZipPackFiles(pFilePath, mZipFileFullPath, false); // 文件
MessageBox("OK");
}
void CTestzipDlg::OnBtnunzip()
{
// TODO: Add your control notification handler code here
CString m_strDirPath= "";
GetModuleFileName(NULL, m_strDirPath.GetBufferSetLength(MAX_PATH+1), MAX_PATH);
m_strDirPath.ReleaseBuffer();
int nPos = m_strDirPath.ReverseFind('\\');
m_strDirPath = m_strDirPath.Left(nPos);
// 工作路径下测试-解压: 删除bin目录下src、zip.h
CZipImplement czip;
CString pFilePath = m_strDirPath+"\\";
CString mZipFileFullPath = m_strDirPath+"\\src.zip";
pFilePath.Replace("\\", "/");
mZipFileFullPath.Replace("\\", "/");
czip.ZipUnPackFiles(mZipFileFullPath, pFilePath, true); // 文件夹
pFilePath = m_strDirPath;
mZipFileFullPath = m_strDirPath+"\\zip.zip";
pFilePath.Replace("\\", "/");
mZipFileFullPath.Replace("\\", "/");
czip.ZipUnPackFiles(mZipFileFullPath, pFilePath, false); // 文件
MessageBox("OK");
}
{
// TODO: Add your control notification handler code here
CString m_strDirPath= "";
GetModuleFileName(NULL, m_strDirPath.GetBufferSetLength(MAX_PATH+1), MAX_PATH);
m_strDirPath.ReleaseBuffer();
int nPos = m_strDirPath.ReverseFind('\\');
m_strDirPath = m_strDirPath.Left(nPos);
// 工作路径下测试--压缩: 删除bin目录下src.zip、zip.zip
CZipImplement czip;
CString pFilePath = m_strDirPath+"\\src";
CString mZipFileFullPath = m_strDirPath+"\\src.zip";
pFilePath.Replace("\\", "/");
mZipFileFullPath.Replace("\\", "/");
czip.ZipPackFiles(pFilePath, mZipFileFullPath, true); // 文件夹
pFilePath = m_strDirPath+"\\zip.h";
mZipFileFullPath = m_strDirPath+"\\zip.zip";
pFilePath.Replace("\\", "/");
mZipFileFullPath.Replace("\\", "/");
czip.ZipPackFiles(pFilePath, mZipFileFullPath, false); // 文件
MessageBox("OK");
}
void CTestzipDlg::OnBtnunzip()
{
// TODO: Add your control notification handler code here
CString m_strDirPath= "";
GetModuleFileName(NULL, m_strDirPath.GetBufferSetLength(MAX_PATH+1), MAX_PATH);
m_strDirPath.ReleaseBuffer();
int nPos = m_strDirPath.ReverseFind('\\');
m_strDirPath = m_strDirPath.Left(nPos);
// 工作路径下测试-解压: 删除bin目录下src、zip.h
CZipImplement czip;
CString pFilePath = m_strDirPath+"\\";
CString mZipFileFullPath = m_strDirPath+"\\src.zip";
pFilePath.Replace("\\", "/");
mZipFileFullPath.Replace("\\", "/");
czip.ZipUnPackFiles(mZipFileFullPath, pFilePath, true); // 文件夹
pFilePath = m_strDirPath;
mZipFileFullPath = m_strDirPath+"\\zip.zip";
pFilePath.Replace("\\", "/");
mZipFileFullPath.Replace("\\", "/");
czip.ZipUnPackFiles(mZipFileFullPath, pFilePath, false); // 文件
MessageBox("OK");
}
// 这样就可以了,程序内容大家都知道。我是为了方便,在类中使用了bool来分辨是文件 还是 文件夹。
// 工程和demo下载地址:http://download.csdn.net/detail/welove20101/7341291
0 0
- 压缩解压缩文件和文件夹(三)
- 压缩解压缩文件和文件夹(一)
- 压缩解压缩文件和文件夹(二)
- 文件/文件夹LZSS压缩/解压缩
- Python压缩文件夹/解压缩zip文件
- Python压缩文件夹/解压缩zip文件
- zip4j加密压缩、解压缩文件、文件夹
- Java文件压缩与解压缩(三)
- 使用tar和gzip对某文件夹内的某类型文件进行压缩与解压缩
- .Net 下利用ICSharpCode.SharpZipLib.dll实现文件/文件夹压缩、解压缩(改进)
- zip压缩/解压缩带空文件夹的文件
- 使用zip对文件或文件夹进行压缩, 解压缩
- 使用zip对文件或文件夹进行压缩, 解压缩
- IOS解压缩和压缩zip文件
- C# 用ICSharpCode解压缩文件和文件夹
- Java解压缩技术(三)BZIP2压缩-解压缩
- 如何在 Windows 2000 中使用 COMPRESS、COMPACT 和 EXPAND 命令压缩或解压缩文件和文件夹
- Java实现zip文件压缩(单个文件、文件夹以及文件和文件夹的组合压缩)
- oracle_sql 基础 (4)
- 负载均衡(Load Balance)技术介绍
- 【LeetCode】Evaluate Reverse Polish Notation
- Hadoop2.2.0启动异常 - Incompatible clusterIDs
- 单发射与多发射
- 压缩解压缩文件和文件夹(三)
- 关于mysql数据库中文乱码的一些总结
- 腾讯财付通充值 数字证书控件未能正常工作
- Android特效开发(仿zaker用手向上推动的效果(推动门效果))
- 图像处理的基本概念
- linux中uptime命令
- oracle_sql 基础 (5)
- 拓展训练:开拓创新、挑战困难
- ListView优化