none
Compress and Extract using System.IO.Compression.ZipFile in 4.5.1. RRS feed

  • Question

  • Hello,

    Looking at "How to: Compress and Extract Files" using Visual Studio 2015 and Framework 4.5.1.  The sample code at does not compile. I had just installed VS2015 as the code does not work in VS2012.  Tried Frameworks 4.5, 4.5.1, 4.5.2, and 4.6 without success.  Any thoughts?

    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);
            }
        }
    }

    ZipFile comes back with the following error message:


    Severity


    Code


    Description


    Project


    File


    Line


    Error


    CS0103


    The name 'ZipFile' does not exist in the current context


    CompressExtractFiles2


    C:\TracSvn\non-gis\CompressExtractFiles2\CompressExtractFiles2\Program.cs


    19

    Tuesday, October 13, 2015 6:01 PM

Answers

All replies