Topic "Progressbar update"

Author Message
MrVinc
[View user's profile]

Joined: 2016-02-22
Posts: 1
Location: Ger
Hello,
i upload files via SCP and want to see the status in a Progressbar.
How did i update the progressbar?

Here my Code for the upload with a backgroundworker:


Code:
 private void frm_main_Load(object sender, EventArgs e)
        {
            worker = new BackgroundWorker();
            worker.WorkerReportsProgress = true;
            worker.WorkerSupportsCancellation = true;

            worker.DoWork += new DoWorkEventHandler(worker_DoWork);

        }


        private void btn_hochladen_Click(object sender, EventArgs e)
        {

            worker.RunWorkerAsync(2000);

        }

        void worker_DoWork(object sender, DoWorkEventArgs e)
        {

           if (arguments.Length > 1)
            {



                for (int i = 1; i < arguments.Length; i++) // Loop through array
                {

                    using (Session session = new Session())
                    {

                        // Connect
                        session.Open(sessionOptions);


                        // Upload files
                        TransferOptions transferOptions = new TransferOptions();
                        transferOptions.TransferMode = TransferMode.Binary;


                        TransferOperationResult transferResult;
                        string path = "/recalbox/share/roms/" + folder + "/";
                        transferResult = session.PutFiles(@"" + String.Join(", ", arguments[i]), path, false, transferOptions);
                        //transferResult = session.PutFiles(@"" + String.Join(", ", arguments[i]), "/recalbox/share/test/", false, transferOptions);


                        // Throw on any error
                        transferResult.Check();

                        // Print results
                        //foreach (TransferEventArgs transfer in transferResult.Transfers)
                        //{
                        //    MessageBox.Show(transfer.FileName);

                        //}

                    }

                }


            }
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24553
Location: Prague, Czechia
Use Session.FileTransferProgress event:
https://winscp.net/eng/docs/library_session_filetransferprogress
Advertisements

You can post new topics in this forum






Search Site

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License