Zip on-the-fly compression library in C for streaming
libarchive supports any format you want, on the fly and even in-memory files.
Zip library options for the Compact Framework?
Have a look at #ziplib (www.icsharpcode.com). It's GPL, but you can use it in closed-source, commercial applications. They don't say anything specifically on their page about using it with the Compact Framework, so you'd have to give it a test yourself (that said, it's pure C# without any external dependencies, so the chances are somewhat good that it will work).
C++ file container (e.g. zip) for easy access
The answer depends on whether you plan to modify the archive via code after the archive is initially built.
If you don't need to modify it, you can use TAR - it's a handy and simple format. If you want compression, you can implement tar.gz reader or find some library that does this (I believe there are some available, including open-source ones).
If your application needs random access to the data or it needs to modify the archive, then regular TAR or ZIP archives are not good. Virtual file system such as our SolFS or CodeBase file system will fit much better: virtual file systems are suited for frequent modifications of the storage, while archives target mainly write-once-read-many usage scenarios.
Standalone Cross Platform (Windows/Linux)) File Compression for C/C++?
What's wrong with zlib (that's the obvious first thing to look at; everybody uses that) or libzip (first hit on freshmeat)?
- zlib: The library itself only provides the compression, but there is a sample implementation of zip format you can use. The "zlib license" is slightly modified MIT/X license, so should be compatible. Trivial to build as part of your application.
- libzip: Supports zip format. BSD-revised license; you have to maintain it, but it's basically equivalent to MIT/X license. Can also be linked statically.
In general, there is no technical reason why you'd need to link anything dynamically. You don't. There is, however, a legal reason for LGPL-licensed libraries, because LGPL stops at dynamic object boundary, so static linking makes the other code LGPL as well.
How do I execute WinZip from Visual Studio without it's GUI opening?
I'd agree with the other's answers about using a different utility. However, to answer your question: the link that you posted also mentions another option -min
to run WinZip minimized. Did you try that? Also, instead of using system
, try using ShellExecute
and ask for the window to be hidden:
ShellExecute(NULL, NULL, "C:\\Program Files\\WinZip\\winzip32", "-a C:\\LOG\\test.zip C:\\LOG\\LOG_7-20-2010_17_8_48_834.csv", NULL, SW_HIDE);
Creating a ZIP file on Windows (XP/2003) in C/C++
EDIT: This answer is old, but I cannot delete it because it was accepted. See the next one
https://stackoverflow.com/a/121720/3937
----- ORIGINAL ANSWER -----
There is sample code to do that here
[EDIT: Link is now broken]
http://www.eggheadcafe.com/software/aspnet/31056644/using-shfileoperation-to.aspx
Make sure you read about how to handle monitoring for the thread to complete.
Edit: From the comments, this code only works on existing zip file, but @Simon provided this code to create a blank zip file
FILE* f = fopen("path", "wb");
fwrite("\x50\x4B\x05\x06\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", 22, 1, f);
fclose(f);
Building Portable Class Library Project in build server fails
A more general and elegant solution is to install the latest Microsoft .NET Portable Library Reference Assemblies. This will install profile138 among many others.
The standalone installer(s) can be found at:
- 4.6 (June 2014):
Portable Class Library Projects Dont Work with NuGet
As far as I know Visual Studio 2012 does not include any Portable Class Libraries. They are installed with Visual Studio 2013. Otherwise you will have to install them yourself which involves several steps.
- Install the Portable Library Tools and the Portable Library Reference Assemblies 4.6.
- Extract the PCLs from the .zip file that the Portable Library Reference Assemblies 4.6 installs into
C:\Program Files (x86)\Microsoft .NET Portable Library Reference Assemblies 4.6
. - Copy the PCLs extracted into
C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETPortable
. - Repair the Xamarin install so it adds its PCL profile xml files to the new PCL directories.
Related Topics
How to Generate Random Numbers in C++
How to Do Input Validation in C++ with Cin
Lifetime of Lambda Objects in Relation to Function Pointer Conversion
How Performing Multiple Matrix Multiplications in Cuda
How to Avoid Including Class Implementation Files
Why Can't I Do Polymorphism with Normal Variables
What Is _Declspec and When Do I Need to Use It
How to Update Gcc in Mingw on Windows
Why Does Wide File-Stream in C++ Narrow Written Data by Default
Training Custom Svm to Use with Hogdescriptor in Opencv
_Iterator_Debug_Level Value '0' Doesn't Match Value '2'
Somehow Register My Classes in a List
How to Connect a Signal to a Static Slot Without a Receiver Instance
Detecting Simulated Keyboard/Mouse Input
Difference Between Initialization of Static Variables in C and C++