共享点中的ZipFile无法正常工作 [英] ZipFile in sharepoint not working

查看:61
本文介绍了共享点中的ZipFile无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Response.Clear();
Response.ContentType = "application/zip";
 
Response.AddHeader("content-disposition", "filename=" + "Test.xlsx");
 
string path = @"C:\ReportsDocs";
 
using (ZipFile zip = new ZipFile())
{                          
 
   zip.AddFile(path + @"\docProps\core.xml", "docProp");
   zip.AddFile(path + @"\docProps\app.xml", "docProp");
   zip.AddFile(path + @"\docProps\thumbnail.wmf", "docProp"); 
                          
   zip.Save(Response.OutputStream);
 

}


上面的代码在asp.net中可以正常工作,但在sharepoint中却不能.
Ionic.Zip dll用于创建zip文件.无法从文件读取数据.
请帮助我.


The above code is working fine in asp.net but not in sharepoint.
Ionic.Zip dll is used for creating zip file. It could not read the data from files.
Please help me.

推荐答案

我认为问题出在文件"C:/"的位置.实际上,在任何情况下都不会使用硬编码的路径名.随处可见,而不仅仅是在Silverlight中.您始终应该计算所有路径.而且"C:/"之类的位置实际上对于应用程序数据是非法的,尤其是在Windows 7中.

使用HTTP服务器,您只能使用网站的根路径进行访问.

—SA
I would assume the problem is the location of the file, "C:/". In fact, there are no situations where hard-coded path name could be useful. Anywhere, not just in Silverlight. You always should calculate all paths. And locations like "C:/" are actually illegal for application data, especially in Windows 7.

With HTTP servers, you can have access only withing the root path of the Web site.

—SA


这篇关于共享点中的ZipFile无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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