Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • User (Old forums)
    Post count: 23064
    #19828 |

    I am trying to apply filters to a source folder(containg sub folders too) and zip the filtered files keeping the structure unchanged and at the same time removing the filted files from the source folder.

    How to do this?

    Imported from legacy forums. Posted by Sri (had 2191 views)

    Xceed Support
    Post count: 5658

    To filter files, you can use our Xceed.FileSystem.Filter class. Here is a little code snippet I used to take files from a folder, copy them into an archive and delete the files (from the source folder) that I did not add to the archive.

    AbstractFolder sourceFolder = new DiskFolder( @”D:\SourceFolder” );

    AbstractFile zipFile = new DiskFile( @”D:\” );

    ZipArchive archive = new ZipArchive( zipFile );

    //Copy the .txt files to the archive
    sourceFolder.CopyFilesTo( archive, true, true, “*.txt” );

    AbstractFile[] files = sourceFolder.GetFiles(true, new NotFilter( new NameFilter(“*.txt”)));

    foreach( AbstractFile file in files )
    //Delete the non .txt files of the source Folder

    From the help section, informations on the use of filters:

    Imported from legacy forums. Posted by CharlesB (had 3259 views)

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.