PowerTCP Zip Compression for .NET
Add(String) Method
Example 




A file and path of a file to add to the archive, or a file and path that includes wildcards specifying multiple files to add to the archive.
Adds an item or items to the archive.
Syntax
<DescriptionAttribute("To add one or more items to the collection. ")>
Public Overloads Sub Add( _
   ByVal source As String _
) 
Dim instance As Archive
Dim source As String
 
instance.Add(source)
[Description("To add one or more items to the collection. ")]
public void Add( 
   string source
)
[Description("To add one or more items to the collection. ")]
public: void Add( 
   string* source
) 
[Description("To add one or more items to the collection. ")]
public:
void Add( 
   String^ source
) 

Parameters

source
A file and path of a file to add to the archive, or a file and path that includes wildcards specifying multiple files to add to the archive.
Remarks

Use this method to add a file or multiple files (using wildcards) to the archive. Compress the added files by using the Archive.Zip method.

If using wildcards, Archive.ExcludePattern and Archive.IncludeSubs can be used to fine tune the operation.

Multiple sources can be added using the Archive.Delimiter, which defaults to a comma (,) but can be set to an alternative value.

Example
The following example demonstrates several Add techniques and a zip operation.
' Be sure to import the namespace by putting "Imports Dart.PowerTCP.Zip"
' at the top of your class.

' Add a file using the ArchiveItem constructor
Dim item = New ArchiveItem("c:\Test\\file1.txt")

' Add a comment to this item
item.Comment = "This is file1.txt"

' Use encryption for just this item
item.Encryption = Encryption.Standard
item.Password = "testme"

Archive1.Add(item)

' Add a file using the filename.  This could also be used for adding wildcard collections
Archive1.Add("c:\Test\file2.log")

' Add a wildcard collection of files
' In this case, all "txt" files in the directory "c:\Test" are added, except "file1.txt"
' Subfolders are not included, but the paths are preserved.
Archive1.IncludeSubs = True
Archive1.ExcludePattern = "file1.txt"
Archive1.PreservePath = True
Archive1.Add("c:\Test\*.txt")

' zip the data
Archive1.Zip("c:\test.zip")
// Be sure to import the namespace by putting "using Dart.PowerTCP.Zip;"
// at the top of your class.

// Add a file using the ArchiveItem constructor
ArchiveItem item = new ArchiveItem("c:\\Test\\file1.txt");

// Add a comment to this item
item.Comment = "This is file1.txt";

// Use encryption for just this item
item.Encryption = Encryption.Standard;
item.Password = "testme";

archive1.Add(item);

// Add a file using the filename.  This could also be used for adding wildcard collections
archive1.Add("c:\\Test\\file2.log");

// Add a wildcard collection of files
// In this case, all "txt" files in the directory "c:\Test" are added, except "file1.txt"
// Subfolders are not included, but the paths are preserved.
archive1.IncludeSubs = true;
archive1.ExcludePattern= "file1.txt";
archive1.PreservePath = true;
archive1.Add("c:\\Test\\*.txt");

// Zip the data
archive1.Zip("c:\\test.zip");
See Also

Reference

Archive Class
Archive Members
Overload List


PowerTCP Zip for .NET Documentation Version 2.1.1
© 2018 Dart Communications. All Rights Reserved.
Send comments on this topic