Home Forums .NET libraries Xceed SFTP/FTP for .NET Progress Bar + AsyncFtpClient

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #21190 |

    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.

    Applies to Xceed FTP for .NET. Imported from legacy forums. Posted by too (had 2360 views)

    User (Old forums)
    Member
    Post count: 23064

    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.

     

    Applies to Xceed FTP for .NET. Imported from legacy forums. Posted by André (had 2543 views)

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.