如果路径来自web.config,则不会访问远程文件

时间:2015-03-30 14:36:57

标签: c#

在web.config中,

 <add key="Uploads"  value="\\\\192.19.165.115\\image_dir\\"/>

C#代码:

 uploadsPath = (ConfigurationManager.AppSettings["Uploads"].ToString()); 

使用以下语句返回文件

return File("\\\\192.19.165.115\\image_dir\\" + name, System.Net.Mime.MediaTypeNames.Application.Octet, name);

但是,使用这行代码会导致错误。

return File(uploadsPath + name, System.Net.Mime.MediaTypeNames.Application.Octet, name);

错误:

[COMException (0x80070006): The handle is invalid. (Exception from HRESULT: 0x80070006 (E_HANDLE))]
[HttpException (0x80004005): An error occurred while communicating with the remote host. The error code is 0x80070006.]

两者都是相同的路径。请指导我解决这个问题。

1 个答案:

答案 0 :(得分:0)

在Web配置中,值应为:

 <add key="Uploads"  value="\\192.19.165.115\image_dir\"/>
相关问题