设为首页 加入收藏

TOP

使用VC++压缩解压缩文件夹(二)
2014-11-23 19:19:21 】 浏览:717
Tags:使用 压缩 文件夹
34 if ((pFilePath == L"") || (mZipFileFullPath == L""))
35 {
36 //路径异常返回
37 return FALSE ;
38 }
39
40 if(!CZipImplement::FolderExist(pFilePath))
41 {
42 //要被压缩的文件夹不存在
43 return FALSE ;
44 }
45
46 CString tZipFilePath = mZipFileFullPath.Left(mZipFileFullPath.ReverseFind('\\') + 1);
47 if(!CZipImplement::FolderExist(tZipFilePath))
48 {
49 //ZIP文件存放的文件夹不存在创建它
50 wchar_t* temp=tZipFilePath.GetBuffer(tZipFilePath.GetLength());
51 if (FALSE == CreatedMultipleDirectory(temp))
52 {
53 //创建目录失败
54 return FALSE;
55 }
56 }
57
58 //获得文件夹的名字
59 if(pFilePath.Right(1) == L"\\")
60 {
61 this->m_FolderPath = pFilePath.Left(pFilePath.GetLength() - 1);
62 m_FolderName = m_FolderPath.Right(m_FolderPath.GetLength() - m_FolderPath.ReverseFind('\\') - 1);
63 }
64 else
65 {
66 this->m_FolderPath = pFilePath;
67 m_FolderName = pFilePath.Right(pFilePath.GetLength() - pFilePath.ReverseFind('\\') - 1);
68 }
69
70 /************************************************************************/
71
72 //创建ZIP文件
73 hz=CreateZip(mZipFileFullPath,0);
74 if(hz == 0)
75 {
76 //创建Zip文件失败
77 return FALSE;
78 }
79
80 //递归文件夹,将获取的问价加入ZIP文件
81 BrowseFile(pFilePath);
82 //关闭ZIP文件
83 CloseZip(hz);
84
85 /************************************************************************/
86
87 CFileFind tFFind;
88 if (!tFFind.FindFile(mZipFileFullPath))
89 {
90 //压缩失败(未发现压缩后的文件)
91 return FALSE;
92 }
93
94 return TRUE;
95}
96
97/////////////////////////////////////////////////////////////////////////////
98// 函数说明: 解压缩文件夹
99// 参数说明: [in]: mUnPackPath 解压后文件存放的路径
100// mZipFileFullPath ZIP文件的路径
101// 返回值:
102// 函数作者:
103// 创建日期: 2009-09-27 上午 11:04:28
104/////////////////////////////////////////////////////////////////////////////
105BOOL CZipImplement::Zip_UnPackFiles(CString &mZipFileFullPath, CString& mUnPackPath)
106{
107 //参数错误
108 if ((mUnPackPath == L"") || (mZipFileFullPath == L""))
109 {
110 //路径异常返回
111 return FALSE ;
112 }
113
114 CFileFind tFFind;
115 if (!tFFind.FindFile(mZipFileFullPath))
116 {
117 //压缩失败(未发现压缩文件)
118 return FALSE;
119 }
120
121 //如果解压缩的路径不存在 试图创建它
122 CString tZipFilePath = mUnPackPath;
123 if(!CZipImplement::FolderExist(tZipFilePath))
124 {
125 //解压后存放的文件夹不存在 创建它
126 wchar_t* temp=tZipFilePath.GetBuffer(tZipFilePath.GetLength());
127 if (FALSE == CreatedMultipleDirectory(temp))
128 {
129 //创建目录失败
130 return FALSE;
131 }
132 }
133 /************************************************************************/
134 //打开ZIP文件
135 hz=OpenZip(mZipFileFullPath,0);
136 if(hz == 0)
137 {
138 //打开Zip文件失败
139 return FALSE;
140 }
141
142
首页 上一页 1 2 3 4 下一页 尾页 2/4/4
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇VC中Tab control的用法 下一篇VC实现将对话框最小化到系统托盘

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目