设为首页 加入收藏

TOP

使用VC++压缩解压缩文件夹(三)
2014-11-23 19:19:21 】 浏览:716
Tags:使用 压缩 文件夹
zr=SetUnzipBaseDir(hz,mUnPackPath);
143 if(zr != ZR_OK)
144 {
145 //打开Zip文件失败
146 CloseZip(hz);
147 return FALSE;
148 }
149
150 zr=GetZipItem(hz,-1,&ze);
151 if(zr != ZR_OK)
152 {
153 //获取Zip文件内容失败
154 CloseZip(hz);
155 return FALSE;
156 }
157
158 int numitems=ze.index;
159 for (int i=0; i
160 {
161 zr=GetZipItem(hz,i,&ze);
162 zr=UnzipItem(hz,i,ze.name);
163
164 if(zr != ZR_OK)
165 {
166 //获取Zip文件内容失败
167 CloseZip(hz);
168 return FALSE;
169 }
170 }
171
172 CloseZip(hz);
173 return TRUE;
174}
175
176/////////////////////////////////////////////////////////////////////////////
177// 函数说明: 检查指定的文件夹是否存在
178// 参数说明: [in]:strPath 检查的文件夹 (此方法会主动向路径末尾添加*.*)
179// 返回值:BOOL类型,存在返回TRUE,否则为FALSE
180// 函数作者:
181// 创建日期: 2009-09-27 下午 02:16:36
182/////////////////////////////////////////////////////////////////////////////
183BOOL CZipImplement::FolderExist(CString& strPath)
184{
185 CString sCheckPath = strPath;
186
187 if(sCheckPath.Right(1) != L"\\")
188 sCheckPath += L"\\";
189
190 sCheckPath += L"*.*";
191
192 WIN32_FIND_DATA wfd;
193 BOOL rValue = FALSE;
194
195 HANDLE hFind = FindFirstFile(sCheckPath, &wfd);
196
197 if ((hFind!=INVALID_HANDLE_VALUE) &&
198 (wfd.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY) || (wfd.dwFileAttributes&FILE_ATTRIBUTE_ARCHIVE))
199 {
200 //如果存在并类型是文件夹
201 rValue = TRUE;
202 }
203
204 FindClose(hFind);
205 return rValue;
206}
207
208/////////////////////////////////////////////////////////////////////////////
209// 函数说明: 遍历文件夹
210// 参数说明: [in]:strFile 遍历的文件夹(此方法会主动向路径末尾添加*.*)
211// 返回值:BOOL类型,存在返回TRUE,否则为FALSE
212// 函数作者:
213// 创建日期: 2009-09-27 下午 02:16:36
214/////////////////////////////////////////////////////////////////////////////
215void CZipImplement::BrowseFile(CString &strFile)
216{
217 CFileFind ff;
218 CString szDir = strFile;
219
220 if(szDir.Right(1) != L"\\")
221 szDir += L"\\";
222
223 szDir += L"*.*";
224
225 BOOL res = ff.FindFile(szDir);
226 while(res)
227 {
228 res = ff.FindNextFile();
229 if(ff.IsDirectory() && !ff.IsDots())
230 {
231 //如果是一个子目录,用递归继续往深一层找
232 CString strPath = ff.GetFilePath();
233
234 CString subPath;
235 GetRelativePath(strPath,subPath);
236 //将文件添加到ZIP文件
237 ZipAddFolder(hz,subPath);
238 BrowseFile(strPath);
239 }
240 else if(!ff.IsDirectory() && !ff.IsDots())
241 {
242 //显示当前访问的文件(完整路径)
243 CString strPath = ff.GetFilePath();
244 CString subPath;
245
246 GetRelativePath(strPath,subPath);
247 //将文件添加到ZIP文件
248 ZipAdd(hz,subPath,strPath);
249 }
250 }
251
252 //关闭
253 ff.Close();
254}
255
256/////////////////////////////////////////////////////////////////////////////
257// 函
首页 上一页 1 2 3 4 下一页 尾页 3/4/4
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇VC中Tab control的用法 下一篇VC实现将对话框最小化到系统托盘

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目