WebRequest req = WebRequest.Create("file://192.168.1.11/s/a.txt");
NetworkCredential cred = new NetworkCredential("administrator", "5", "192.168.1.11");
req.Credentials = cred;
WebResponse response = req.GetResponse();
Stream strm = response.GetResponseStream();
StreamReader r = new StreamReader(strm);执行以上代码时报错
System.Net.WebException: Access to the path '\\192.168.1.11\s\a.txt' is denied. --->
System.Net.WebException: Access to the path '\\192.168.1.11\s\a.txt' is denied. --->
System.UnauthorizedAccessException: Access to the path '\\192.168.1.11\s\a.txt' is denied.我的目的是向远程服务器端的文本文件插入数据
NetworkCredential cred = new NetworkCredential("administrator", "5", "192.168.1.11");
req.Credentials = cred;
WebResponse response = req.GetResponse();
Stream strm = response.GetResponseStream();
StreamReader r = new StreamReader(strm);执行以上代码时报错
System.Net.WebException: Access to the path '\\192.168.1.11\s\a.txt' is denied. --->
System.Net.WebException: Access to the path '\\192.168.1.11\s\a.txt' is denied. --->
System.UnauthorizedAccessException: Access to the path '\\192.168.1.11\s\a.txt' is denied.我的目的是向远程服务器端的文本文件插入数据
http://dotnet.aspx.cc/file/Upload-Files-TO-UNC-Share-Using-ASP.NET.aspx后面的代码方法
String content = File.ReadAllText("\\\\192.168.1.11\\s\\a.txt");