English 中文(简体)
Unziping files to existing directories in Visual Studio 2005 C++?
原标题:

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.

问题回答

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.

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.





相关问题
Why running a service as Local System is bad on windows?

I am trying to find out the difference between difference service account types. I tumbled upon this question. The answer was because it has powerful access to local resources, and Network Service ...

Programmatically detect Windows cluster configuration?

Does anyone know how to programatically detect that a Windows server is part of a cluster? Further, is it possible to detect that the server is the active or passive node? [Edit] And detect it from ...

get file icon for Outlook appointment (.msg)

I ve read Get File Icon used by Shell and the other similar posts - and already use SHFileInfo to get the associated icon for any given extension, and that works great. However, Outlook uses ".msg" ...

Identifying idle state on a windows machine

I know about the GetLastInputInfo method but that would only give me the duration since last user input - keyboard or mouse. If a user input was last received 10 minutes ago, that wouldn t mean the ...

Terminating a thread gracefully not using TerminateThread()

My application creates a thread and that runs in the background all the time. I can only terminate the thread manually, not from within the thread callback function. At the moment I am using ...

热门标签