sharpziplib

SharpZipLib Examine and select contents of a ZIP file

强颜欢笑 提交于 2019-12-12 10:43:28
问题 I am using SharpZipLib in a project and am wondering if it is possible to use it to look inside a zip file, and if one of the files within has a data modified in a range I am searching for then to pick that file out and copy it to a new directory? Does anybody know id this is possible? 回答1: Yes, it is possible to enumerate the files of a zip file using SharpZipLib. You can also pick files out of the zip file and copy those files to a directory on your disk. Here is a small example: using (var

System.IOException when opening file with File.OpenRead

走远了吗. 提交于 2019-12-11 17:26:42
问题 I get the following exception when I open a file for unzipping it's contents. It happens when I have the file selected in Windows Explorer, or mouse over it showing a tooltip. System.IO.IOException was unhandled Message=The process cannot access the file 'D:\Documents\AutoUnZip\Zips\MVCContrib.Extras.release.zip' because it is being used by another process. Source=mscorlib StackTrace: at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) at System.IO.FileStream.Init(String

How to decompress .bz2 file in C#?

拈花ヽ惹草 提交于 2019-12-11 03:56:53
问题 I am developing wpf application. I am using sharpziplib to compress and decompress files. I am easily decompress the .zip files using following code public static void UnZip(string SrcFile, string DstFile, string safeFileName, int bufferSize) { //ICSharpCode.SharpZipLib.Zip.UseZip64.Off; FileStream fileStreamIn = new FileStream(SrcFile, FileMode.Open, FileAccess.Read); ZipInputStream zipInStream = new ZipInputStream(fileStreamIn); string rootDirectory = string.Empty; if (safeFileName.Contains

Request admin privileges to edit system files

本小妞迷上赌 提交于 2019-12-11 03:19:58
问题 New to C#, I'm developing a windows form application inside visual studio. The app uses ICSharpCode.SharpZipLib library to update a zip's content. When the zip file is inside a non system partition, say like D:\myzip.zip the files gets updated correctly. But, if the zip is in the system partition, C:\myzip.zip the app returns an error; Could not find file C:\myzip.zip even though the file is there! This has to do with admin privileges because when I run the app as administrator it works. The

ICSharpCode.SharpZipLib.Zip crc32

天大地大妈咪最大 提交于 2019-12-10 23:53:41
问题 I am using ICSharpCode.SharpZipLib.Zip to compress the files and folders and pass it as memorystream using response.Binary write. Here is my code: MemoryStream df= new MemoryStream(); ZipOutputStream s = new ZipOutputStream(df); s.SetLevel(9); byte[] data = (byte[])file.OpenBinary(); s.Write(data, 0, data.Length); s.Finish(); s.Close(); byte[] outBuf = df.GetBuffer(); Response.Expires = 0; Response.Buffer = true; Response.ClearContent(); Response.AddHeader("content-disposition", "inline;

SharpZipLib - adding folders/directories to a zip archive

自作多情 提交于 2019-12-10 23:20:53
问题 From examples, I've got a pretty good grasp over how to extract a zip file. In nearly every example, the method of identifying when a ZipEntry is a directory is as follows string directoryName = Path.GetDirectoryName(theEntry.Name); string fileName = Path.GetFileName(theEntry.Name); if (directoryName.Length > 0) Directory.CreateDirectory(Path.Combine(destinationDirectory, directoryName)); if (fileName != String.Empty) { //read data and write to file } Now is is fine and all (directory

Problems opening .xlsx file created with EPPlus and zipped in a folder with ICSharpCode.SharpZipLib

╄→гoц情女王★ 提交于 2019-12-10 18:08:26
问题 I am creating a list of ExcelPackages (xlsx documents) using EPPlus, and adding them to a ZipOutputStream as ZipEntries. I think the Excel documents should be valid, as I can open them just fine when I write one of them to the Response object without zipping. The zip folder is created as expected, and the file(s) are there and doesnt seem to be empty, but when I try to open them I get the following error in Excel: Excel cannot open the file {Name}.xlsx because the file format or file

How to use ICSharpCode.ZipLib with stream?

早过忘川 提交于 2019-12-10 16:27:07
问题 I'm very sorry for the conservative title and my question itself,but I'm lost. The samples provided with ICsharpCode.ZipLib doesn't include what I'm searching for. I want to decompress a byte[] by putting it in InflaterInputStream(ICSharpCode.SharpZipLib.Zip.Compression.Streams.InflaterInputStream) I found a decompress function ,but it doesn't work. public static byte[] Decompress(byte[] Bytes) { ICSharpCode.SharpZipLib.Zip.Compression.Streams.InflaterInputStream stream = new ICSharpCode

Make a .tar.gz archive without folder structure using SharpZipLib

给你一囗甜甜゛ 提交于 2019-12-10 13:24:57
问题 I am trying to .tar.gz a list of files from a folder using SharpZipLib. The problem is no matter how pass the files paths - the result always contains the files paths - and not only the files thems selves. What am i missing here? string filesFolder = "c:\\testfolder\\test\\"; List<string> filesToZip = new List<string>() { filesFolder +"test1", filesFolder +"test2"}; using (FileStream fs = new FileStream(filesFolder +"myGz.tar.gz" , FileMode.Create, FileAccess.Write, FileShare.None)) using

C#: Extract a zipped file only (without the folder)

回眸只為那壹抹淺笑 提交于 2019-12-08 05:08:14
问题 With the SharpZip lib I can easily extract a file from a zip archive: FastZip fz = new FastZip(); string path = "C:/bla.zip"; fz.ExtractZip(bla,"C:/Unzips/",".*"); However this puts the uncompressed folder in the output directory. Suppose there is a foo.txt file within bla.zip which I want. Is there an easy way to just extract that and place it in the output directory (without the folder)? 回答1: The FastZip does not seem to provide a way to change folders, but the "manual" way of doing