当前位置: 首页>>代码示例>>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;未经允许,请勿转载。