仅压缩特定文件 [英] Zipping a Particular File only

查看:77
本文介绍了仅压缩特定文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我想压缩单个文件并将其保存在该文件夹中...但该文件的容器文件夹也会被压缩..例如:尝试使用路径D压缩文件:\ fol1 \ fol2 \ file.xlsx会给出一个包含fol1 \ fol2 \ file.xlsx的压缩文件夹...但是大小正在压缩...是我的代码...



 进口 Ionic.Zip 
使用 zip 作为 Ionic.Zip.ZipFile = Ionic.Zip.ZipFile
zip.AddFile( D:\ SA\Updates \RESults\UPDATED_DUMP.xlsx
zip.Save( D:\\ \\ updates\results\UPDATED_DUMP.zip
结束 使用





我做错了吗?



感谢您的帮助...

解决方案

< blockquote>查看在线文档: ZipFile类 [ ^ ]


尝试下面

 进口 Ionic.Zip 
使用 zip 作为 Ionic.Zip.ZipFile = Ionic.Zip .ZipFile
zip.AddFile( D:\ SA\Updates\results\UPDATED_DUMP。 xlsx
zip .Save( D:\ SA\Updat es\results\UPDATED_DUMP.zip
结束 使用



参考: http:// stackoverflow.com/questions/4125607/dotnetzip-add-files-without-creating-folders [ ^ ]


Hi All,

I want to zip a single file and save it in that folder only...But the container folder of that file is also getting zipped..Example: trying to zip a file with path D:\fol1\fol2\file.xlsx gives a zipped folder containing fol1\fol2\file.xlsx...But the size is getting compressed..here is my code...

Imports Ionic.Zip
Using zip As Ionic.Zip.ZipFile = New Ionic.Zip.ZipFile
zip.AddFile("D:\SA\Updates\results\UPDATED_DUMP.xlsx")
zip.Save("D:\SA\Updates\results\UPDATED_DUMP.zip")
End Using



Am I doing anything wrong??

Thanks for help...

解决方案

Check online documentation: ZipFile class[^]


try below

Imports Ionic.Zip
Using zip As Ionic.Zip.ZipFile = New Ionic.Zip.ZipFile
zip.AddFile("D:\SA\Updates\results\UPDATED_DUMP.xlsx", "")
zip.Save("D:\SA\Updates\results\UPDATED_DUMP.zip")
End Using


reference:http://stackoverflow.com/questions/4125607/dotnetzip-add-files-without-creating-folders[^]


这篇关于仅压缩特定文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆