dotnetzip

DotNetZip How Add Selected Files without creating folders

限于喜欢 提交于 2019-12-23 05:16:02
问题 I want to add in zip file "test" all pdf files from path using (var zip = new ZipFile()) { zip.AddSelectedFiles("*.pdf",path); zip.Save(path+"/test.zip"); } when test.zip file is created have this directory : **test.zip**\Users\administrator\Documents\vs2010\Projects\my project\**pdf files** How to make all pdf documents to be directly in test.zip test.zip\pdf files 回答1: Please try the following, using (ZipFile zip = new ZipFile()) { string[] files = Directory.GetFiles(path); // filter the

Compression issue with large archive of files in DotNetZip

≡放荡痞女 提交于 2019-12-22 08:45:00
问题 Greetings.... I am writing a backup program in c# 3.5, using hte latest DotNetZip. The basics of the program is to be given a location on a server and the max size of a spanned zip file and go. From there it should traverse all the folder/files from the given location and add them to the archive, keeping the exact structure. It should also compress everything down to a reasonable amount. A given uncompressed collection of folders/files could easily be 10-25gb, with the created spanned files

Create and stream image archive zip file for download C#

白昼怎懂夜的黑 提交于 2019-12-21 06:18:25
问题 I am using the beloved DotNetZip archiving library in MVC3 to generate a Zip file on the fly which contains .png images from binaries stored in a database. I then stream the generated Zip file out for the user to download. (I validate image data prior to saving to to the database, so you can assume that all image data is valid). public ActionResult PictureExport() { IEnumerable<UserPicture> userPictures = db.UserPicture.ToList(); //"db" is a DataContext and UserPicture is the model used for

DotNetZip trouble with coding

杀马特。学长 韩版系。学妹 提交于 2019-12-19 21:24:25
问题 I am using DotNetZip. When i am archiving file which have english name all normally. but when i archiving file with russian names in result archive with bad names of file. Some peoplese said that string ZipConstants.DefaultCodePage = 866; But it not compile. I also use zip.UseUnicodeAsNecessary properties, and convert my file names to utf8 and utf7. 回答1: To create a unicode zip file in DotNetZip: using (var zip = new ZipFile()) { zip.UseUnicodeAsNecessary= true; zip.AddFile(filename,

C# : How to report progress while creating a zip file?

送分小仙女□ 提交于 2019-12-18 07:01:50
问题 Update: Got it working updated my working code Here is what I have so far private async void ZipIt(string src, string dest) { await Task.Run(() => { using (var zipFile = new ZipFile()) { // add content to zip here zipFile.AddDirectory(src); zipFile.SaveProgress += (o, args) => { var percentage = (int)(1.0d / args.TotalBytesToTransfer * args.BytesTransferred * 100.0d); // report your progress pbCurrentFile.Dispatcher.Invoke( System.Windows.Threading.DispatcherPriority.Normal, new Action(

C# : How to report progress while creating a zip file?

一个人想着一个人 提交于 2019-12-18 07:01:28
问题 Update: Got it working updated my working code Here is what I have so far private async void ZipIt(string src, string dest) { await Task.Run(() => { using (var zipFile = new ZipFile()) { // add content to zip here zipFile.AddDirectory(src); zipFile.SaveProgress += (o, args) => { var percentage = (int)(1.0d / args.TotalBytesToTransfer * args.BytesTransferred * 100.0d); // report your progress pbCurrentFile.Dispatcher.Invoke( System.Windows.Threading.DispatcherPriority.Normal, new Action(

Using a MemoryStream with FileStreamResult possible?

荒凉一梦 提交于 2019-12-18 05:28:09
问题 I'm using DotNetZip to create a zip file and pass it to a FileResult. On debug, I can verify that the MemoryStream contains a file, but when I run it through FileStreamResult, it returns 0bytes: public FileResult GetZipFiles(int documentId) { var file = fileRepository.Get(documentId); var zip = new ZipFile(); var stream = new MemoryStream(); var filePath = Path.Combine(UploadsFolder, Path.GetFileName(file.Id)); zip.AddFile(filePath); zip.Save(stream); var result = new FileStreamResult(stream,

Set password on Zip file using DotNetZip

≡放荡痞女 提交于 2019-12-17 19:17:55
问题 I'm using DotNetZip to zip my files, but I need to set a password in zip. I tryed: public void Zip(string path, string outputPath) { using (ZipFile zip = new ZipFile()) { zip.AddDirectory(path); zip.Password = "password"; zip.Save(outputPath); } } But the output zip not have password. The parameter path has a subfolder for exemple: path = c:\path\ and inside path I have subfolder What is wrong? 回答1: Only entries added after the Password property has been set will have the password applied. To

Extracting zip from stream with DotNetZip

廉价感情. 提交于 2019-12-13 18:20:00
问题 public void ZipExtract(Stream inputStream, string outputDirectory) { using (ZipFile zip = ZipFile.Read(inputStream)) { Directory.CreateDirectory(outputDirectory); zip.ExtractSelectedEntries("name=*.jpg,*.jpeg,*.png,*.gif,*.bmp", " ", outputDirectory, ExtractExistingFileAction.OverwriteSilently); } } [HttpPost] public ContentResult Uploadify(HttpPostedFileBase filedata) { var path = Server.MapPath(@"~/Files"); var filePath = Path.Combine(path, filedata.FileName); if (filedata.FileName.EndsWith

DotNetZip in BackgroundWorker update progressbar and label on a form

落花浮王杯 提交于 2019-12-13 07:46:57
问题 I'm creating option to backup data of my app with DotNetZip and to avoid freezing the app I've found that the best way for a this type of action best way is to use BackgroundWorker. So I came with something like this: private void processButton_Click(object sender, EventArgs e) { BackgroundWorker worker = new BackgroundWorker(); worker.WorkerReportsProgress = true; worker.DoWork += new DoWorkEventHandler(worker_DoWork); worker.ProgressChanged += new ProgressChangedEventHandler(worker