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.我的目的是向远程服务器端的文本文件插入数据

解决方案 »

  1.   

    你可以参考ImpersonateUser方法,
    http://dotnet.aspx.cc/file/Upload-Files-TO-UNC-Share-Using-ASP.NET.aspx后面的代码方法
      

  2.   

    file://192.168.1.11/s/a.txt,这个可以打开的
      

  3.   

    你的administrator和密码5是哪个机器上的帐号?
      

  4.   

    你可以使用
    String content  = File.ReadAllText("\\\\192.168.1.11\\s\\a.txt");
      

  5.   

    String content = File.ReadAllText("\\\\192.168.1.11\\s\\a.txt");使用这个还是报错