简体   繁体   中英

Download a zip file from one folder location to another

using Ionic.Zip;

var savedzipFile = "C:\alldocs\issues\issuesfromtoday.zip";
var selectedfolderfromDialog = "D:\MyDocs";

This is what I have. I cant use webblient because its not a url. How to I save the zip file to that selected folder location? Zip file has PDFs if that matters.

This should do the trick:

var savedzipFile = @"C:\alldocs\issues\issuesfromtoday.zip";
var selectedfolderfromDialog = @"D:\MyDocs";
using (var sourceStream = System.IO.File.Open(savedzipFile, System.IO.FileMode.Open))
{ 
    using (var targetStream = System.IO.File.OpenWrite(selectedfolderfromDialog + @"\" + savedzipFile.Substring(savedzipFile.LastIndexOf('\\'))))
    { 
        sourceStream.CopyTo(targetStream);
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM