Locked Upload error with FtpWebRequest

  • Tuesday, March 13, 2012 4:06 PM
     
     

    With VST 2008 when i make upload with this code after 2.15 hours i have an error.

    The FTP server send a status code 200 but the file of 23 go is always not complete about 10%.

    It's always between 2.15 -2.30 h of upload.

    Any solutions ?

    We try some library and always the same error.

    Many tests have be made in few computer with different internet providers.

     FileInfo fileInfo = new FileInfo((@psRepertoire + @psFichier).Replace(@"\\", @"\"));
                        FtpWebRequest request = (FtpWebRequest)WebRequest.Create(this.lParams.Options.OptionsWebvox.ServeurFtp + psFichier);
                        request.Method = WebRequestMethods.Ftp.UploadFile;
                        request.Credentials = new NetworkCredential(this.lParams.Options.OptionsWebvox.UsagerFtp, this.lParams.Options.OptionsWebvox.MotPasseFtp);
                        request.UsePassive = true;
                        request.UseBinary = true;
                        request.KeepAlive = false;
                        request.ContentLength = fileInfo.Length;
                        request.Timeout = 999999999;
                        request.ReadWriteTimeout = 999999999;
                        long filesize = fileInfo.Length;
                        Application.DoEvents();
                        using (FileStream stream = File.OpenRead((@psRepertoire + @psFichier).Replace(@"\\", @"\")))
                        {
                            using (Stream uploadStream = request.GetRequestStream())
                            {
                                System.DateTime ldDateDebut = System.DateTime.Now;
                                long totalWritten = 0;
                                byte[] buffer = new byte[2048];
                                int bytesRead = 0;
                                while ((bytesRead = stream.Read(buffer, 0, buffer.Length)) > 0)
                                {
                                    uploadStream.Write(buffer, 0, bytesRead);
                                    uploadStream.Flush();
                                    totalWritten += bytesRead;
                                    if (this.InvokeRequired == true)
                                        this.Invoke(new MethodInvoker(delegate() { MajProgessionUpload(totalWritten, filesize, ldDateDebut); }));
                                    else
                                        MajProgessionUpload(totalWritten, filesize, ldDateDebut);
                                }
                            }


    Frederic fv Villeneuve


All Replies