【C#-1或更多字节与GZip往返的截断】教程文章相关的互联网学习教程文章

C# .NET 使用第三方类库DotNetZip解压/压缩Zip文件 (ZT)【代码】

DotNetZip on CodePlex: http://dotnetzip.codeplex.com/ 详细的可以看源代码……总之感觉比SharpZipLib好用。而且DotNetZip支持VB,C#以及任何.NET语言。 加压:(从CodePlex上偷过来的) using (ZipFile zip = new ZipFile()){// add this map file into the "images" directory in the zip archive 把这个PNG文件添加到zip档案的"images"目录下zip.AddFile("c:\\images\\personal\\7440-N49th.png", "images");// add the repor...

c# – zip中的Zip打开到未记录的System.IO.Compression.SubReadStream【代码】

我有一个函数用于聚合来自zip存档的流.private void ExtractMiscellaneousFiles() {foreach (var miscellaneousFileName in _fileData.MiscellaneousFileNames){var fileEntry = _archive.GetEntry(miscellaneousFileName);if (fileEntry == null){throw new ZipArchiveMissingFileException("Couldn't find " + miscellaneousFileName);}var stream = fileEntry.Open();OtherFileStreams.Add(miscellaneousFileName, (DeflateStre...

c# – 用zip替换同名文件【代码】

我有一个代码,可以创建或添加文件到指定的zip存档.如果我试图添加另一个具有相同名称的文件,我找不到的是替换zip文件的选项.private void button1_Click(object sender, EventArgs e){if (oflFilesToZip.ShowDialog() == DialogResult.OK){string[] files = oflFilesToZip.FileNames;bool zipExists = File.Exists(zipPath);ZipArchive zip;if (zipExists){zip = ZipFile.Open(zipPath, ZipArchiveMode.Update);}else zip = ZipFil...

如何将.zip文件视为C#中的目录?

我希望能够像读取物理文件夹中的文件一样读取zip文件中的文件.如何在不提取文件的情况下执行此操作?解决方法:有一些组件允许您从.NET应用程序中查看.zip文件的内容: > http://www.icsharpcode.net/opensource/sharpziplib/ – (免费开源)> http://xceed.com/Zip_Net_Intro.html – (商业) 我之前使用过#ziplib,但它的工作原理并不是很广泛.

c# – DotNetZip检查zip文件中是否存在文件夹【代码】

我试图检查zip文件中是否存在文件夹.代码如下://All entries refered too exists. //For files (Workes fine, returns true) var hello1 = zip.Any(entry => entry.FileName.Equals(@"Patients.xml")); var hello2 = zip.Any(entry => entry.FileName.Equals(@"Bookings.xml"));//For folders (Dosent work (returns false)) var result1 = zip.Any(entry => entry.FileName.Equals(@"PatientsF")); var result2 = zip.Any(entry ...

c# – 将目录添加到现有的.zip文件中【代码】

首先,我想说我已经尝试寻找解决方案,我没有找到一个我不必解压缩,添加我的文件夹,然后再拉链.我没有使用任何第三方库.如果可能的话,我想使用system.io.compression来做这个…如果不是,我会使用dotnetzip作为我的最后手段. TL;博士.我希望能够将包含文件的目录添加到已创建的zip文件中.这可以使用system.io.compression库吗? 编辑:using (FileStream zipToOpen = new FileStream(zipfile, FileMode.Open)){using (ZipArchive arch...

c# – 这是否可以压缩带有zip库的JPEG文件【代码】

据我所知,jpeg文件在其他图像扩展之间具有最佳压缩比,如果我更正,我们无法再压缩jpeg文件,因为它具有最佳压缩,所以请帮助我.我创建了一些jpegs如下:ImageCodecInfo[] codecs = ImageCodecInfo.GetImageEncoders(); ImageCodecInfo ici = null; foreach(ImageCodecInfo codec in codecs) { if(codec.MimeType == "image/jpeg")ici = codec; } EncoderParameters ep = new EncoderParameters(); ep.Param[0] = new EncoderParameter...

c#-将SQLite数据库直接添加到Zip文件【代码】

我试图在内存中创建一个SQLite数据库,然后将其直接添加到我创建的zip文件中.到目前为止,我可以使用ZipArchive和ZipFile类创建zip文件.但是,我找不到将在内存中创建的SQLite数据库添加到zip容器的方法. 以下是我必须在内存中创建数据库的代码:private static void MemoryDB(){SQLiteConnection conn = new SQLiteConnection("Data Source = :memory:");conn.Open();String sql = "CREATE TABLE highscores (name VARCHAR(25), scor...

c# – 是否可以使用.NET或其他内置Windows API在保持层次结构的同时解压缩zip文件?【代码】

我有一个包含文件夹层次结构和文件的zip文件.\images\images\1.jpg \images\2.jpg \something\something\a.exe \something\something\b.exe 1.txt我需要将此zip文件的内容解压缩到一个位置.我还需要保留zip文件的结构. 我读过.NET的GZipStream和DeflateStream,但我认为它太复杂了“. 我过去也曾将DotNetZip和SharpZipLib用于个人项目,但由于这是与工作相关的,而且我在一家大公司工作,我很难说服合法使用这些库. 题:是否可以使用.N...

GZIP - 相关标签