本文介绍了从远程服务器上载/下载文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个asp.net Web应用程序.我正在尝试从远程服务器(在本地网络上)访问文件,但是很遗憾,它无法正常工作.问题是我不确定错误是否是cos所提及的路径不正确,或者这是iis7权限的问题.我在web.config文件中设置了< identity impersonate ="true"....以下是我尝试访问的代码:

Hi I have an asp.net web application. I am trying to access files from remote server (on local network) and unfortunately it isn’t working out. Problem is I am not sure if the error is cos the path mentioned isn’t correct or is this a problem with iis7 permissions. I have set <identity impersonate="true"... in web.config file. Below is the code i am trying to access :

Response.AppendHeader("content-disposition", "attachment; filename=" +
 document.FileName);
 Response.ContentType = document.ContentType;
 String filepath = "\\<server-name>\<shared folder>\file.txt";
 Response.WriteFile(filepath);
 Response.End();



我尝试了文件路径字符串的所有可能组合.什么都行不通.请帮忙.



I have tried every possible combination of filepath string. Nothing works. Please help.

推荐答案


String filepath = @"\\<server-name>\\<shared folder>\\test.txt";



我得到了例外:

找不到文件




I get the exception:

"Could not find file


''\\\\<server-name>\\<shared folder>\\test.txt''



更新SM:当您输入@时,不要使用转义序列!请看书!
尝试:



UPDATE SM: When you put @, you don''t use escape sequences! Read books please!
try:

String filepath = @"\\<server-name>\<shared folder>\test.txt";



这篇关于从远程服务器上载/下载文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-03 19:54