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

    Hi,
    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
    Member
    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.

    e.g.,<code>
    AbstractFolder sourceFolder = new DiskFolder( @”D:\SourceFolder” );

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

    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
    file.Delete();
    }
    </code>

    From the help section, informations on the use of filters:
    http://doc.xceedsoft.com/products/XceedFileSystem/Using_filters.html

    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.