日期:2014-05-17  浏览次数:20697 次

求改个C#函数为断点续传?
求个高手帮忙,,我改了半天好像不行。。。正在找相关例子看,路过的高手给点提示也行


        /// <summary>
        /// 上传
        /// </summary>
        /// <param name="filename"></param>
        public void Upload(string filename)
        {

            FileInfo fileInf = new FileInfo(filename);
            string uri = ftpURI + fileInf.Name;
            FtpWebRequest reqFTP;

            reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri(uri));
            reqFTP.Credentials = new NetworkCredential(ftpUserID, ftpPassword);
            reqFTP.KeepAlive = false;
            reqFTP.Method = WebRequestMethods.Ftp.UploadFile;
            reqFTP.UseBinary = true;
            reqFTP.ContentLength = fileInf.Length;
            //记录文件总字节
            ftpUploadFizeSize = fileInf.Length;

            int buffLength = 2048;
            byte[] buff = new byte[buffLength];
            int contentLen;
            FileStream fs = fileInf.OpenRead();
            
            try
            {
                //把上传的文件写入流
                Stream strm = reqFTP.GetRequestStream();
                //每次读文件流的kb
                contentLen = fs.Read(buff, 0, buffLength);
                ftpUploadCurrLen += contentLen;
                //流内容没有结束
                while (contentLen != 0)
                {
                    //把内容从file stream写入upload stream
    &nb