This topic demonstrates how to add items to a Tar archive using the static Tar method of the QuickTar class, specifying several parameters.
Tar is not currently available in Xceed's Compact Framework products.
Tar method
The Tar method has various overloads that can be used to add files to a Tar archive. Some only require that you specify the archive name and the files to add to the archive, while others provide options such as whether existing files should be replaced and the directory structure preserved in the destination Tar archive, whether the Tar operation should be performed recursively, and whether the archive should be compressed using GZip to "tarFileName".gz. Events are also supported. For details on the other overloads, see the reference documentation.
Demonstration
In the following example, we specify several parameters and also use some callbacks.
VB.NET | Copy Code |
---|---|
|
C# | Copy Code |
---|---|
|
Remarks
When recursively adding files to a zip file, you have to consider every filename you place in the filesToTar parameter as a filemask. For example, if you set the filesToTar parameter to "c:\file.txt", the entire "c:\" drive will be scanned and all the files that are named "file.txt" that are found will be included in the Tar archive.
Note that the filesToTar parameter of the Tar method cannot be null; otherwise, an ArgumentNullException exception will be thrown.
Things you should consider
The main questions you should ask yourself when adding items to a Tar archive are:
-
Do you want to do more complex Tar operations? Use the FileSystem-based classes defined within the Xceed.Tar namespace.