1 public partial class Form1 : Form 2 { 3 public Form1() 4 { 5 InitializeComponent(); 6 WebClient webClient = new WebClient(); 7 Stream stream = webClient.OpenWrite("http://localhost/accept/newfile.txt","PUT");//这句出错,无法连接到远程服务器 8 StreamWriter streamWriter = new StreamWriter(stream); 9 streamWriter.WriteLine("Hello World"); 10 streamWriter.Close(); 11 } 12 }
是什么原因?机子设置问题吗
把URL放到你本机浏览器,能打开:问题在你代码,不能问题在服务器