Welcome to the Xceed Community | Help
Community Search  
More Search Options

Progress Bar + AsyncFtpClient

Sort Posts: Previous Next
  •  04-24-2009, 4:19 PM Post no. 20540

    Progress Bar + AsyncFtpClient

    Hi, i have a very simple UI App. A form with a button and a progress bar.

    One requrement i have is that my xceed functions ( connect, upload, etc) have to be in a dirrefernt class ( ie i cant have functions at the same place as code for the form).

    Code for my main form:

    namespace MagicFolderFTP

    {

    public partial class Form2 : Form

    {

    public Form2() {

    InitializeComponent();

    Xceed.Ftp.Licenser.LicenseKey = "XXXX-XXXX-XXXX-XXXX";

    }

    private void btnUpload_Click(object sender, EventArgs e) {

    FTPWrapper fw = new FTPWrapper();

    fw.ftpServerIP = "localhost";

    fw.ftpUserID = "anonymous";

    fw.Upload(@"D:\magicfolder\IE8ALapAround.wmv");

     

    }

    public void file_transfer(object sender, FileTransferStatusEventArgs e)

    {

    progressBar1.Value = e.AllBytesPercent;

    } } }

    code for FTP class

    using Xceed.Ftp;

    using Xceed.FileSystem;

    namespace MagicFolderFTP

    {

    class FTPWrapper

    {

    public string ftpServerIP;

    public string ftpUserID;

    public string ftpPassword;

    public void Upload(string localPath)

    {

    AsyncFtpClient client = new AsyncFtpClient();

    client.Connect(ftpServerIP);

    //client.SynchronizingObject = ??????; <--- what do i need to put here?

    client.Login();

    //client.FileTransferStatus += new FileTransferStatusEventHandler(); < --- some how reference a method on a Form?

    client.SendFile(localPath);

    client.Disconnect();

    } } }

    Any help appreciated.

  •  04-27-2009, 3:04 PM Post no. 20573 in reply to 20540

    Re: Progress Bar + AsyncFtpClient

    If the ProgressBar is on Form2, then the SynchronizingObject is Form2.

    Leave the event handler (file_transfer) in the FTP class, the library will automatically make the call on the main thread.  You can refer to the ProgessBar in the event handler through the Form2 reference you will use to set the SynchronizingObject.

     


    André
    Software Developer
    Xceed Software Inc.
View as RSS news feed in XML
Contact | Site Map | Reviews | Legal Terms of Use | Trademarks | Privacy Statement Copyright 2011 Xceed Software Inc.