[英]c# access files from different server
I had a requirement of reading a XML document from the server on which the application is running. 我需要从运行应用程序的服务器上读取XML文档。 I am able to do it by simply accessing a file by passing string url as the parameter.
我可以通过简单地通过传递字符串url作为参数来访问文件来做到这一点。
XmlDocument doc = new XmlDocument();
doc.Load(fullPath); //fullPath is a string. for e.x. c:\myfolder\myxml.xml
Now the requirement changes to access the file from a different server so for that I am simply modifying my fullPath
as 现在,要求更改为从另一台服务器访问文件,为此,我只是将
fullPath
修改为
\\p.o.r.t\c$\myfolder\myxml.xml
But it fails to read the file. 但是它无法读取文件。 Is there some other way to access files placed on a different server.
还有其他方法可以访问放置在其他服务器上的文件。
PS : If I use the same URL and paste it in URL, I am able to access the file. PS :如果我使用相同的URL并将其粘贴到URL中,则可以访问该文件。
So I finally figured it out. 所以我终于想通了。 The folder which I was trying to access wasn't shared for the
Authenticated Users
. 我尝试访问的文件夹未与
Authenticated Users
共享。 Sharing it solved the problem. 共享它解决了问题。
Here is some posts that contains a valid answer: 以下是一些包含有效答案的帖子:
Access files from network share in c# web app 从C#Web应用程序中的网络共享访问文件
Asp.net Access To Network Share Asp.net访问网络共享
and detailed problem explained here: 详细的问题在这里说明:
http://support.microsoft.com/kb/207671 http://support.microsoft.com/kb/207671
Good luck 祝好运
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.