将文件解压缩到 Visual Studio 2005 C++ 中的现有目录?
我的客户端计算机服务器上可能有一个预先存在的目录结构,如下所示:
-|
+css
|-ABC
|-EFG
|-XYZ
+img
|-ABC
|-EFG
|-XYZ
+js
|-ABC
|-EFG
|-XYZ
+htm
|-ABC
|-EFG
|-XYZ
当我们将客户更新发送到他们的电子商务网站时,我们以 zip 文件形式发送它们,该文件具有以下结构:
-|
+css
|-UniqueDirectory
+img
|-UniqueDirectory
+js
|-UniqueDirectory
+htm
|-UniqueDirectory
...其中 UniqueDirectory总是同一个名字。
话虽这么说,有没有一种方法可以使用 Visual C++ 2005 编写一个程序来将我们发送给客户的 zip 文件解压到现有目录中,而不覆盖任何现有目录(当然不包括 UniqueDirectory,这可以而且应该)被覆盖)。
文件在客户端计算机上解压缩后的最终结果应该是:
-|
+css
|-ABC
|-EFG
|-UniqueDirectory
|-XYZ
+img
|-ABC
|-EFG
|-UniqueDirectory
|-XYZ
+js
|-ABC
|-EFG
|-UniqueDirectory
|-XYZ
+htm
|-ABC
|-EFG
|-UniqueDirectory
|-XYZ
可以使用 C++ 完成此操作吗?我的客户不具备将文件解压缩到正确目录所需的技术技能。他们也不一定想要安装解压缩程序。
它需要外部库吗?我最好只使用 Visual C++ 2005 中的库来完成此操作,但如果需要外部库,我想知道它的名称。
I have a possibly pre-existing directory structure on the client machine server that looks like this:
-|
+css
|-ABC
|-EFG
|-XYZ
+img
|-ABC
|-EFG
|-XYZ
+js
|-ABC
|-EFG
|-XYZ
+htm
|-ABC
|-EFG
|-XYZ
When we send our customers updates to their e-commerce websites we send them in a zip file, which has the following structure:
-|
+css
|-UniqueDirectory
+img
|-UniqueDirectory
+js
|-UniqueDirectory
+htm
|-UniqueDirectory
...where UniqueDirectory is always the same name.
That being said, is there a way using Visual C++ 2005 that a program could be written to unzip the zip file that we send the customer into the existing directory without overwriting any of the existing directories (excluding the UniqueDirectory of course, that can and should be overwritten).
The end result after the file being unzipped on the client machine should be:
-|
+css
|-ABC
|-EFG
|-UniqueDirectory
|-XYZ
+img
|-ABC
|-EFG
|-UniqueDirectory
|-XYZ
+js
|-ABC
|-EFG
|-UniqueDirectory
|-XYZ
+htm
|-ABC
|-EFG
|-UniqueDirectory
|-XYZ
Can this be done using C++? My clients don't possess the technical skill involved to just unzip the files to the correct directories. They also don't necessarily want to install an unzipping program.
Would it require an external library? Preferably I'd like to do this using just libraries from Visual C++ 2005, but if an external library is required I'd like to know what it is called.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
除非您想仅使用 VS2005 提供的功能自己实现压缩/解压缩算法,否则您将需要考虑使用库来为您完成工作。我推荐 zlib。它是免费的。
网站上有操作方法。
编辑:针对您评论中的问题,是的,它已经足够老了,可以由 VS2005 构建。我刚刚下载了最新的源代码并能够将其编译为
.dll
。我下载的副本是“zlib源代码,版本1.2.3,zip文件格式”。提取文件后,查找 /projects/visualc6/ 目录。您应该能够从那里构建库。或者,您也可以从 zlib 站点下载预编译的库。它与源文件下载一起列出为“zlib 编译的 DLL,版本 1.2.3,zip 文件格式”。
编辑:请记住,zlib 是一个C 库。如果您正在寻找C++库,您可以尝试gzstream,它基本上是 zlib 的 C++ 包装器。
Unless you want to implement the compression/decompression algorithm yourself using only what is available with VS2005, you'll want to look in to using a library to do your work for you. I recommend zlib. It's free.
There's a how-to on the site.
Edit: In response to the question in your comment, yes it is old enough to be build by VS2005. I just downloaded the latest source and was able to compile it into a
.dll
. The copy I downloaded was "zlib source code, version 1.2.3, zipfile format". After you extract the files, look for the /projects/visualc6/ directory. You should be able to build the library from there.Alternatively you can also download a pre-compiled library from the zlib site. It's listed with the source file downloads as "zlib compiled DLL, version 1.2.3, zipfile format".
Edit: Keep in mind that zlib is a C library. If you're looking for a C++ library, you might try gzstream, which is basically a C++ wrapper around zlib.
不,MFC/ATL没有这样的能力。除非您算上随 Visual Studio 安装并可通过 C++/CLI 使用的 J# 可再发行组件,否则您需要外部库或重新发明轮子。
No, MFC/ATL do not have such capability. Unless you count the J# redistributable that is installed with Visual Studio and can be used via C++/CLI, you need an external library or reinvent the wheel.