Beispiel #1
0
    public void ExtractArchive(string archiveFilenameIn, string outFolder)
    {
        if (!FS.ExistsDirectory(outFolder))
        {
            FS.CreateDirectory(outFolder);
        }
        ZipFile zf = null;

        try
        {
            FileStream fs = File.OpenRead(archiveFilenameIn);
            zf = new ZipFile(fs);
            foreach (ZipEntry zipEntry in zf)
            {
                String entryFileName = zipEntry.Name;
                byte[] buffer        = new byte[4096];  // 4K is optimum
                Stream zipStream     = zf.GetInputStream(zipEntry);

                // Manipulate the output filename here as desired.
                String fullZipToPath = FS.Combine(outFolder, entryFileName).TrimEnd(AllChars.bs);
                string directoryName = FS.GetDirectoryName(fullZipToPath);
                if (directoryName.Length > 0)
                {
                    FS.CreateDirectory(directoryName);
                }

                using (FileStream streamWriter = File.Create(fullZipToPath))
                {
                    StreamUtils.Copy(zipStream, streamWriter, buffer);
                }
            }
        }
        finally
        {
            if (zf != null)
            {
                zf.IsStreamOwner = true; // Makes close also shut the underlying stream
                zf.Close();              // Ensure we release resources
            }
        }
    }
Beispiel #2
0
    public void GetTargetTest()
    {
        TestHelper.Init();

        var d  = SetFor(LinkType.D);
        var td = JunctionPoint.GetTarget(d);
        // target2 - also folder
        var rd = JunctionPoint.GetTarget(target2);
        var ed = FS.ExistsDirectory(d);

        var j  = SetFor(LinkType.J);
        var tj = JunctionPoint.GetTarget(j);
        //var rj = JunctionPoint.GetTarget(target);
        var ej = FS.ExistsDirectory(j);

        SetFor(LinkType.H);
        var h  = SetFor(LinkType.H);
        var th = JunctionPoint.GetTarget(h);
        var rh = JunctionPoint.GetTarget(target);
        var eh = FS.ExistsDirectory(h);
    }