标签:技术分享 文件 [] images string 环境 pca div span
<add key="键值" value="\\IP地址\Attachments" />
<identity impersonate="true" userName="docshareuser" password="密码" />
测试上传成功!下载时报错:
因为下载的方法如下:
context.Response.AppendHeader("Content-Length", fileSize.ToString()); context.Response.CacheControl = HttpCacheability.Public.ToString(); context.Response.Cache.AppendCacheExtension("max-age=" + 365 * 24 * 60 * 60); context.Response.Cache.SetExpires(DateTime.Now.AddYears(1)); context.Response.AppendHeader("ETag", "Never_Modify"); context.Response.Cache.SetETag("Never_Modify"); context.Response.Cache.SetLastModified(DateTime.Now.AddMinutes(-1)); context.Response.TransmitFile(filePath);
修改下载方式:
FileStream fs = new FileStream(filePath, FileMode.Open); byte[] bytes = new byte[(int)fs.Length]; fs.Read(bytes, 0, bytes.Length); fs.Close(); Response.ContentType = "application/octet-stream"; //通知浏览器下载文件而不是打开 Response.AddHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8)); context.Response.BinaryWrite(bytes); context.Response.Flush(); context.Response.End();
标签:技术分享 文件 [] images string 环境 pca div span
原文地址:http://www.cnblogs.com/swanchen/p/6210860.html