當前位置: 首頁>>代碼示例>>C#>>正文


C# FtpWebRequest.BeginGetRequestStream方法代碼示例

本文整理匯總了C#中System.Net.FtpWebRequest.BeginGetRequestStream方法的典型用法代碼示例。如果您正苦於以下問題:C# FtpWebRequest.BeginGetRequestStream方法的具體用法?C# FtpWebRequest.BeginGetRequestStream怎麽用?C# FtpWebRequest.BeginGetRequestStream使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Net.FtpWebRequest的用法示例。


在下文中一共展示了FtpWebRequest.BeginGetRequestStream方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: UploadNextFile

 private void UploadNextFile(IAsyncResult ar)
 {
     //清空
     _currLength = 0;
     _abort = false;
     if (_uploadResponse != null) _uploadResponse.Close();
     if (_fileStream != null) _fileStream.Close();
     if (_requestStream != null) _requestStream.Close();
     _uploadResponse = (FtpWebResponse)_uploadRequest.EndGetResponse(ar);
     //_result = "文件上傳成功";
     try
     {
         if (_uploadFiles.Count != 0)
         {
             FileInfo file = _uploadFiles[0] as FileInfo;
             ServerFileInfo serverFile = SearchFile(file.Name.Replace('#', '_'));
             if (serverFile != null) _currLength = serverFile.Size;
             else _currLength = 0;
             string uploadUrl = @"ftp://" + this.Address + ":" + this.Port + "/" + file.Name.Replace('#', '_');
             _uploadRequest = (FtpWebRequest)WebRequest.Create(uploadUrl);
             if ((bool)_uploadFilesStateTable[file])
             {//覆蓋
                 _uploadRequest.Method = WebRequestMethods.Ftp.UploadFile;
                 _currLength = 0;
             }
             else _uploadRequest.Method = _currLength == 0 ? WebRequestMethods.Ftp.UploadFile : WebRequestMethods.Ftp.AppendFile; 
             _uploadRequest.Credentials = new NetworkCredential(this.UserName, this.Password);
             _uploadRequest.Proxy = null;
             _uploadRequest.KeepAlive = false;
             _uploadRequest.BeginGetRequestStream(new AsyncCallback(TransFile), file);
         }
     }
     catch (Exception e)
     {
         _result = e.Message;
     }
 }
開發者ID:viticm,項目名稱:pap2,代碼行數:37,代碼來源:FTPClient.cs

示例2: UploadFile

 public bool UploadFile(IList files)
 {
     try
     {
         //區分第一次
         if (files != null) _uploadFiles = files;
         _abort = false;
         if (_uploadFiles.Count != 0)
         {
             FileInfo file = _uploadFiles[0] as FileInfo;                    
             //把'#'替換為'_'
             ServerFileInfo serverFile = SearchFile(file.Name.Replace('#','_'));
             if (serverFile != null) _currLength = serverFile.Size;
             else _currLength = 0;
             string uploadUrl = FTP_URL_PREFIX + file.Name.Replace('#', '_');
             _uploadRequest = (FtpWebRequest)WebRequest.Create(uploadUrl);
             if ((bool)_uploadFilesStateTable[file])
             {//覆蓋
                 _uploadRequest.Method = WebRequestMethods.Ftp.UploadFile;
                 _currLength = 0;
             }
             else _uploadRequest.Method = _currLength == 0 ? WebRequestMethods.Ftp.UploadFile : WebRequestMethods.Ftp.AppendFile; 
             _uploadRequest.Credentials = new NetworkCredential(this.UserName, this.Password);
             _uploadRequest.Proxy = null;
             _uploadRequest.KeepAlive = false;
             _uploadRequest.BeginGetRequestStream(new AsyncCallback(TransFile), file);
         }
         return true;
     }
     catch (Exception e)
     {
         _result = e.Message;
         return false;
     }
 }
開發者ID:viticm,項目名稱:pap2,代碼行數:35,代碼來源:FTPClient.cs


注:本文中的System.Net.FtpWebRequest.BeginGetRequestStream方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。