c#解压文件
2024-08-27 00:09:47
今天做了一个异步上传文件后再直接解压的一个东西。到解压这找了好多资料,做了1个多小时,贴出来,给自己张张记性。
HttpPostedFileBase imgFile = Request.Files[0];//获取到文件流
filename = imgFile.FileName;
imgFile.SaveAs(Server.MapPath("../Test/" + filename));//保存到本地
var archive = ArchiveFactory.Open(Server.MapPath("../Test/" + filename));//通过Server.MapPath找到文件的绝对路径
foreach (var entry in archive.Entries)
{
if (!entry.IsDirectory)//开始解压
{
entry.WriteToDirectory(Server.MapPath("../Test/"), ExtractOptions.ExtractFullPath | ExtractOptions.Overwrite);//解压地址也是要绝对路径的
}
}
然后要补充的是需要引用一个dll 叫SharpCompress.dll 下载地址:http://sharpcompress.codeplex.com/#
最新文章
- x01.os.14: 时间都去哪儿了
- git如何放弃所有本地修改?
- Spring与Quartz的整合实现定时任务调度(转)
- hdu 2509 博弈 *
- Oracle子查询(嵌套查询)
- 让所有浏览器包括IE6即支持最大宽度又支持最小宽度。
- C语言中字符数组和字符串指针分析
- Jquery Ajax方法传递json到action
- ul li 好友列表
- SQL点滴15—在SQL Server 2008中调用C#程序
- 推荐xamlspy
- 完美实现身份证校验 js正则
- 控件之combox
- spring中基于注解使用AOP
- Ubantu linux中使用PyCharm之---破解PyCharm,实现永久免费试用
- LoadRunner之IP欺骗
- LINQ(数据库操作增、删、改及并发管理)
- JavaScript和它父亲的故事
- 【xsy1130】tree 树形dp+期望dp
- [BeiJing2006]狼抓兔子
热门文章
- iOS开发零碎知识点
- 通过GitHub Pages建立个人站点总结与体会
- eaysui 利用datagrid 实现左右移除数据
- What technical details should a programmer of a web application consider before making the site public?
- C扩展python的module和Type
- java递归应用
- shell 从1加到100
- 一个简单的loading,纯属自娱自乐
- Download Oracle Forms 6i
- oracle,mysql,SqlServer三种数据库的分页查询的实例。