2012-08-16 78 views

回答

2
WebClient webClient = new WebClient(); 
     string webAddress = null; 
     try 
     { 
      webAddress = @"http://myCompany/ShareDoc/"; 

      webClient.Credentials = CredentialCache.DefaultCredentials; 

      WebRequest serverRequest = WebRequest.Create(webAddress); 
      WebResponse serverResponse; 
      serverResponse = serverRequest.GetResponse(); 
      serverResponse.Close(); 

      webClient.UploadFile(webAddress + logFileName, "PUT", logFileName); 
      webClient.Dispose(); 
      webClient = null; 
     } 
     catch (Exception error) 
     { 
      MessageBox.Show(error.Message); 
     } 
+0

我很抱歉,我不明白,你可以請解釋一下,我也需要上傳文件到web服務器不下載。 – Abdul 2012-08-16 05:10:48

+0

對不起,我讀取下載文件,而不是上傳;-)所以我糾正它 – 2012-08-16 05:18:54

+0

希望它對https也很有用...,無論如何我會嘗試。 – Abdul 2012-08-16 05:25:44