how to download ftp files with auto resume facility
<p>I am having a problem , the problem is i can download ftp files but the files i downoad doesnot have a resume facility adn multi part files download , because there are large file more than 500 mb files i cant download the files continously because i gets disconnect and it start download from beginning i wanted my code a resume facility if it gets disconnect </p>

<p>The code i am using is</p>

<pre><code>    public string[] GetFileList()
    {
        string[] downloadFiles;
        StringBuilder result = new StringBuilder();
        FtpWebRequest reqFTP;
        try
        {
            reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri("ftp://" + ftpServerIP + "/"));
            reqFTP.UseBinary = true;
            reqFTP.Credentials = new NetworkCredential(ftpUserID, ftpPassword);
            reqFTP.Method = WebRequestMethods.Ftp.ListDirectory;
            WebResponse response = reqFTP.GetResponse();
            StreamReader reader = new StreamReader(response.GetResponseStream());
            //MessageBox.Show(reader.ReadToEnd());
            string line = reader.ReadLine();
            while (line != null)
            {
                result.Append(line);
                result.Append("\n");
                line = reader.ReadLine();
            }
            result.Remove(result.ToString().LastIndexOf('\n'), 1);
            reader.Close();
            response.Close();
            //MessageBox.Show(response.StatusDescription);
            return result.ToString().Split('\n');
        }
        catch (Exception ex)
        {
            System.Windows.Forms.MessageBox.Show(ex.Message);
            downloadFiles = null;
            return downloadFiles;
        }
    }


    private void Download(string filePath, string fileName)
    {
        FtpWebRequest reqFTP;
        try
        {
            //filePath = &lt;&lt;The full path where the file is to be created.&gt;&gt;, 
            //fileName = &lt;&lt;Name of the file to be created(Need not be the name of the file on FTP server).&gt;&gt;
            FileStream outputStream = new FileStream(filePath + "\\" + fileName, FileMode.Create);

            reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri("ftp://" + ftpServerIP + "/" + fileName));
            reqFTP.Method = WebRequestMethods.Ftp.DownloadFile;
            reqFTP.UseBinary = true;
            reqFTP.Credentials = new NetworkCredential(ftpUserID, ftpPassword);
            FtpWebResponse response = (FtpWebResponse)reqFTP.GetResponse();
            Stream ftpStream = response.GetResponseStream();
            long cl = response.ContentLength;
            int bufferSize = 2048;
            int readCount;
            byte[] buffer = new byte[bufferSize];

            readCount = ftpStream.Read(buffer, 0, bufferSize);
            while (readCount &gt; 0)
            {
                outputStream.Write(buffer, 0, readCount);
                readCount = ftpStream.Read(buffer, 0, bufferSize);
            }

            ftpStream.Close();
            outputStream.Close();
            response.Close();
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.Message);
        }
    }
</code></pre>

<p>private void btnDownload_Click(object sender, EventArgs e)
        {</p>

<pre><code>        FolderBrowserDialog fldDlg = new FolderBrowserDialog();
        if (txtUpload.Text.Trim().Length &gt; 0)
        {
            if (fldDlg.ShowDialog() == DialogResult.OK)
            {
                Download(fldDlg.SelectedPath, txtUpload.Text.Trim());
            }
        }
        else
        {
            MessageBox.Show("Please enter the File name to download");
        }
    }
</code></pre>

<p>i want resume facility in my code ,</p>

<p>there would be a great appreciation if someone could help me,</p>

<p>Thanks In Advance</p>
