Creates a new zip file.
[Visual Basic]
Public Sub Create( _
fileName As String, _
overwrite As Boolean _
)
Public Sub Create( _
s As Stream _
)
[C#]
public void Create(
string fileName,
bool overwrite
);
public void Create(
Stream s
);
[C++]
public: void Create(
String* fileName,
bool overwrite
);
public: void Create(
Stream* s
);
[JScript]
public function Create(
fileName: String,
overwrite: Boolean
);
public function Create(
s: Stream
);
Parameters
Example
[Visual Basic, C#, C++] The following example demonstrates how to compress/decompress file with EACompression Zip Component. This sample doesn't demonstrates the events, please refer to Samples section to get the full samples of EACompression.
[Visual Basic]
Imports EACompression
Imports System.IO
Sub Zip()
Try
Dim oZip As New ZipArchive("TryIt")
oZip.Create("c:\test.zip", True) 'create a new zip file
Dim password As String = ""
'add a single file to zip file.
oZip.AddFile("c:\test.gif", "", password)
'create zip file by stream
'Dim fs = New FileStream("c:\test.zip", FileMode.Create, FileAccess.ReadWrite)
'oZip.Create(fs)
'oZip.AddFile("c:\test.gif", "", password)
'fs.Close()
Catch ep As Exception
Console.Write(ep.Message)
End Try
End Sub
[C#]
using System;
using System.Collections;
using System.IO;
using EACompression;
void Zip()
{
try
{
ZipArchive oZip = new ZipArchive( "TryIt" );
oZip.Create( "c:\\test.zip", true ); //create a new zip file;
string password = "";
//add a single file to zip file.
oZip.AddFile( "c:\\test.gif", "", password );
//create zip file by stream
//FileStream fs = new FileStream("c:\\test.zip", FileMode.Create, FileAccess.ReadWrite);
//oZip.Create(fs);
//oZip.AddFile("c:\\test.gif", "", password);
//fs.Close();
}
catch( Exception ep )
{
Console.Write( ep.Message );
}
}
[C++]
using namespace System;
using namespace System::Collections;
using namespace System::IO;
using namespace EACompression;
void Zip()
{
try
{
ZipArchive *oZip = new ZipArchive( S"TryIt" );
oZip->Create( S"c:\\test.zip", true ); //create a zip file;
String *password = S"";
//add a single file to zip file.
oZip->AddFile( S"c:\\test.gif", S"", password );
//create zip file by stream
//FileStream *fs = new FileStream(S"c:\\test.zip", FileMode::Create, FileAccess::ReadWrite);
//oZip->Create(fs);
//oZip->AddFile(S"c:\\test.gif", S"", password);
//fs->Close();
}
catch( Exception *ep )
{
Console::Write( ep->Message );
}
}