Introduction
There are many class libraries available for zip files. I found it very easy to operate zip files in C # programs. When Microsoft's. NET framework 1.1 came out, a new language called J # was also released #. Let's take a look at J. Java is the front of the July language. If this is the case, java.util.zip can be used here. It took me some time to find it in vjslib. dll. Let's use it. Create a new C # project and select a Windows application. We can do this as follows:
All we need to do is add reference.
After adding a reference, you can start.
// Output stream
Java. io. FileOutputStream fos = new java. io. FileOutputStream (zipFileName );
// Tie to zip stream
Java.util.zip. ZipOutputStream zos = new java.util.zip. ZipOutputStream (fos );
// Stream with source file
Java. io. FileInputStream FCM = new java. io. FileInputStream (sourceFile );
// It's our entry in zip
Java.util.zip. ZipEntry ze = new java.util.zip. ZipEntry (sourceFile );
Zos. putNextEntry (ze );
Sbyte [] buffer = new sbyte [2, 1024];
Int len;
// Read and write until done
While (len = FS. read (buffer)> = 0)
{
Zos. write (buffer, 0, len );
}
// Close everything
Zos. closeEntry ();
FCM. close ();
Zos. close ();
Fos. close ();