none
system.io.compress missing methods RRS feed

  • Question

  • I am using vs 2015 VB.net and need to be able to add single files to a zip.

    I have donet 4.5 referenced and have inspected the system.io.compress object and I can not filed zipfile.addfile.

    please advis.

    Wednesday, August 19, 2015 3:59 PM

Answers

  • As you have found, the ZipFile class doesn't support adding a file to an existing Zip archive. You might want to take a look at free third party libraries such as DotNetZip or SharpZipLib for additional functionality.
    Wednesday, August 19, 2015 4:23 PM
  • You need this?

    See here for usage example.

    Thursday, August 20, 2015 1:24 AM
    Answerer
  • Hi Hal,

    Please check ZipFile Class in MSDN.

    Namespace:    System.IO.Compression
    Assembly:   System.IO.Compression.FileSystem (in System.IO.Compression.FileSystem.dll)

    Note you should add reference System.IO.Compression.FileSystem.dll

    Here is also a example,  It compresses the contents of a folder into a zip archive, and then extracts that content to a new folder.

    using System;
    using System.IO;
    using System.IO.Compression;
    
    namespace ConsoleApplication
    {
        class Program
        {
            static void Main(string[] args)
            {
                string startPath = @"c:\example\start";
                string zipPath = @"c:\example\result.zip";
                string extractPath = @"c:\example\extract";
    
                ZipFile.CreateFromDirectory(startPath, zipPath);
    
                ZipFile.ExtractToDirectory(zipPath, extractPath);
            }
        }
    }
    

    Best regards,

    Kristin


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, August 20, 2015 3:18 AM

All replies

  • As you have found, the ZipFile class doesn't support adding a file to an existing Zip archive. You might want to take a look at free third party libraries such as DotNetZip or SharpZipLib for additional functionality.
    Wednesday, August 19, 2015 4:23 PM
  • You need this?

    See here for usage example.

    Thursday, August 20, 2015 1:24 AM
    Answerer
  • Hi Hal,

    Please check ZipFile Class in MSDN.

    Namespace:    System.IO.Compression
    Assembly:   System.IO.Compression.FileSystem (in System.IO.Compression.FileSystem.dll)

    Note you should add reference System.IO.Compression.FileSystem.dll

    Here is also a example,  It compresses the contents of a folder into a zip archive, and then extracts that content to a new folder.

    using System;
    using System.IO;
    using System.IO.Compression;
    
    namespace ConsoleApplication
    {
        class Program
        {
            static void Main(string[] args)
            {
                string startPath = @"c:\example\start";
                string zipPath = @"c:\example\result.zip";
                string extractPath = @"c:\example\extract";
    
                ZipFile.CreateFromDirectory(startPath, zipPath);
    
                ZipFile.ExtractToDirectory(zipPath, extractPath);
            }
        }
    }
    

    Best regards,

    Kristin


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, August 20, 2015 3:18 AM