首页 新闻 赞助 找找看

FTP断点续传文件(上传文件)

0
悬赏园豆:30 [已关闭问题] 关闭于 2012-09-15 14:38
        Stream rs;
        public bool Upload(FileInfo localFile, string remoteFileName)
        {
            try
            {
                bool result = false;
                if (localFile.Exists)//判定
                {
                    string url = Host.TrimEnd('/') + RemotePath + remoteFileName;
                    FtpWebRequest request = CreateRequest(url, WebRequestMethods.Ftp.UploadFile);
                    //上传数据
                    Stream rs = request.GetRequestStream();
                    using (FileStream fs = localFile.OpenRead())
                    {

                        byte[] buffer = new byte[4096];//4K
                        int count = fs.Read(buffer, 0, buffer.Length);
                        while (count > 0)
                        {
                            rs.Write(buffer, 0, count);
                            count = fs.Read(buffer, 0, buffer.Length);

                        }
                        fs.Close();
                        result = true;
                    }
                    return result;
                }
            }
            catch (Exception ex)
            {
               
            }
            throw new Exception(string.Format("本地文件不存在,文件路径:{0}", localFile.FullName));
        }
        #endregion

上传大文件的时候出问题,请问应该怎么改

爱程序,爱生活的主页 爱程序,爱生活 | 初学一级 | 园豆:12
提问于:2012-07-08 15:43
< >
分享
所有回答(1)
0

用第三方 控件。或者 自己写一个。

無限遐想 | 园豆:3740 (老鸟四级) | 2012-07-08 16:31
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册