PDF for UWP | ComponentOne
C1.C1Zip Namespace / C1ZipEntryCollection Class / AddAsync Method / AddAsync(StorageFile) Method
File to add to the zip file.
Example

In This Topic
    AddAsync(StorageFile) Method
    In This Topic
    Adds a file to the current zip file.
    Syntax
    'Declaration
     
    
    <AsyncStateMachineAttribute(C1.C1Zip.C1ZipEntryCollection/d__8)> 
    Public Overloads Function AddAsync( _ 
       ByVal file As StorageFile _ 
    ) As Task
    [AsyncStateMachine(C1.C1Zip.C1ZipEntryCollection/d__8)] 
    public Task AddAsync( 
       StorageFile file 
    )

    Parameters

    file
    File to add to the zip file.
    Remarks

    This method is available only in the WinRT version.

    This method is asynchronous, and should normally be used within 'await' statements as shown in the example below.

    Example
    The code below prompts the user for some file names, then adds the files to the current zip archive.
    using Windows.Storage.Pickers;
    var picker = new FileOpenPicker();
    picker.ViewMode = PickerViewMode.List;
    picker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary;
    picker.FileTypeFilter.Add("*");
    var files = await picker.PickMultipleFilesAsync();
    if (files != null)
    {
      foreach (var f in files)
      {
        await _zip.Entries.AddAsync(f);
      }
    }
    See Also