1

i use My.Computer.Network.UploadFile method for file upload to FTP . But i have some problem . My problem is Upload Speed .

Ex: i use some FTP program (FileZilla) and my upload speed 4 Mb/sn. but My.Computer.Network.UploadFile method is 1.20Mb/sn limit .

Why this method is limited ? Can i up Upload speed ?

Ahmet Uğur
  • 462
  • 6
  • 12

1 Answers1

1

Use this code pal and inform me if this will be useful:

        using System.Net;
             // Get the object used to communicate with the server.
            FtpWebRequest request = (FtpWebRequest)FtpWebRequest.Create("ftp://
            XXXXXXXXXXXXXXXXXXXXX/" + "C:/XXXXX.zip");
            request.Method = WebRequestMethods.Ftp.UploadFile;
            request.Credentials = new NetworkCredential("User", "PassWord");

            // Copy the contents of the file to the request stream.
            Stream ftpStream = request.GetRequestStream();
            FileStream file = File.OpenRead("C:/XXXXX.zip");

            int length = 1024;
            byte[] buffer = new byte[length];
            int bytesread = 0;

            do
            {
            bytesread = file.Read(buffer,0,length);
            ftpStream.Write(buffer,0,bytesread);
            }
            while(bytesread != 0);

            file.Close();
            ftpStream.Close();

            MessageBox.Show("Uploaded Successfully");
Mohsen Heydari
  • 7,256
  • 4
  • 31
  • 46
  • FtpWebRequest's speed is 700-800 kb/sn . Any idea ? Maybe app.config edit ? – Ahmet Uğur Feb 22 '13 at 18:17
  • please inform me if these options changes the result (some of them are bound to your FTP server configurations) Request.UseBinary = true; Request.UsePassive = true; Request.KeepAlive = true; – Mohsen Heydari Feb 22 '13 at 18:43
  • not changed ( 700-800 kb-sn ). its very interesting. i use ftp.exe and speed 4 - 6 mb/sn now . – Ahmet Uğur Feb 22 '13 at 19:16
  • may this being useful http://stackoverflow.com/questions/1016690/how-to-improve-the-performance-of-ftpwebrequest – Mohsen Heydari Feb 22 '13 at 19:21