system.io.compression

Invalid zip file after creating it with System.IO.Compression

怎甘沉沦 提交于 2021-02-18 04:50:33
问题 I'm trying to create a zip file that contains one or more files. I'm using the .NET framework 4.5 and more specifically System.IO.Compression namespace. The objective is to allow a user to download a zip file through a ASP.NET MVC application. The zip file is being generated and sent to the client but when I try to open it by doing double click on it I get the following error: Windows cannot open the folder. The compressed (zipped) folder ... is invalid. Here's my code: [HttpGet] public

Invalid zip file after creating it with System.IO.Compression

南笙酒味 提交于 2021-02-18 04:42:45
问题 I'm trying to create a zip file that contains one or more files. I'm using the .NET framework 4.5 and more specifically System.IO.Compression namespace. The objective is to allow a user to download a zip file through a ASP.NET MVC application. The zip file is being generated and sent to the client but when I try to open it by doing double click on it I get the following error: Windows cannot open the folder. The compressed (zipped) folder ... is invalid. Here's my code: [HttpGet] public

How to store a pdf within a zip file, without saving it locally

ⅰ亾dé卋堺 提交于 2020-12-16 06:57:47
问题 I have a zip file within a zip file and inside the inner zip file I have an Excel and a PDF/Tif document. I'm currently developing a tool that reads all these files and store them in the database. Before I used to store both files on a folder first, but since the zip files holds loads of files I received an out of disk space exception. So now I want to try to store the files in the database directly without knowing the folder location. // Path.Combine(exportPathNoZip,entry.FullName) -->

How to store a pdf within a zip file, without saving it locally

孤者浪人 提交于 2020-12-16 06:56:34
问题 I have a zip file within a zip file and inside the inner zip file I have an Excel and a PDF/Tif document. I'm currently developing a tool that reads all these files and store them in the database. Before I used to store both files on a folder first, but since the zip files holds loads of files I received an out of disk space exception. So now I want to try to store the files in the database directly without knowing the folder location. // Path.Combine(exportPathNoZip,entry.FullName) -->

Decompression error : The magic number in GZip header is not correct

不羁的心 提交于 2020-02-24 10:39:32
问题 I am new to System.IO.Compression I am trying to compress and decompress some information. For compression I used code project and it seems to work. I am compressing string at the moment. For decompressing I would like to docompress a Stream This is what I have at the moment var zipString = _compressor.Compress(request); using (var sw = new StreamWriter(req.GetRequestStream())) { sw.Write(zipString); sw.Close(); } WebResponse respStream = req.GetResponse(); Stream resp = respStream

ZipArchive gives Unexpected end of data corrupted error

自作多情 提交于 2019-12-30 07:56:47
问题 I'm trying to create a zip stream on the fly with some byte array data and make it download via my MVC action. But the downloaded file always gives the following corrupted error when opened in windows. And this error when I try to xtract from 7z But note that the files extracted from the 7z is not corrupted. I'm using ZipArchive and the below is my code. private byte[] GetZippedPods(IEnumerable<POD> pods, long consignmentID) { using (var zipStream = new MemoryStream()) { //Create an archive

System.IO.Compression and ZipFile - extract and overwrite

偶尔善良 提交于 2019-12-23 06:56:46
问题 I'm using the standard VB.NET libraries for extracting and compressing files. It works as well but the problem comes when I have to extract and files exist already. Code I use Imports: Imports System.IO.Compression Method I call when it crashes ZipFile.ExtractToDirectory(archivedir, BaseDir) archivedir and BaseDir are set as well, in fact it works if there are no files to overwrite. The problem comes exactly when there are. How can I overwrite files in extraction without use thirdy-part

Adding a directory to an existing .zip file

谁说我不能喝 提交于 2019-12-10 05:33:42
问题 First of all I would like to say that i've tried looking for the solution to this and I haven't found one where I don't have to unzip, add my folder and then zip again. I am not using any third party libraries. I would like to do this using system.io.compression if it's possible at all ... If not I would use dotnetzip as my last resort. tl;dr. I want to be able to add directories with files in them to an already created zip file. Is this possible using the system.io.compression library ? EDIT

C# .NET Missing Method Exception when opening ZipArchive created with System.IO.Compression

倖福魔咒の 提交于 2019-12-01 11:08:07
I have a C# WinForms .NET app in which I'm trying to write to a zip archive and read from it using System.IO.Compression. Here's now I create the ziparchive: public void SaveStdV20ZipProject(string strfilepath, clsProjectInfo GameInfo) { using (var ms = new MemoryStream()) { using (var archive = new ZipArchive(ms, ZipArchiveMode.Create, true)) { string strProjectData = String.Empty; StringBuilder sb = new StringBuilder(); // First, we add the Game Info data... sb.AppendLine(GameInfo.strGameVersion); sb.AppendLine(GameInfo.strProjectType); sb.AppendLine(GameInfo.strGameTitle); sb.AppendLine

C# .NET Missing Method Exception when opening ZipArchive created with System.IO.Compression

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-01 07:29:22
问题 I have a C# WinForms .NET app in which I'm trying to write to a zip archive and read from it using System.IO.Compression. Here's now I create the ziparchive: public void SaveStdV20ZipProject(string strfilepath, clsProjectInfo GameInfo) { using (var ms = new MemoryStream()) { using (var archive = new ZipArchive(ms, ZipArchiveMode.Create, true)) { string strProjectData = String.Empty; StringBuilder sb = new StringBuilder(); // First, we add the Game Info data... sb.AppendLine(GameInfo