hi there .. i am developing a web application and need to show the progress, i send a thred to threadpool then need control of progress event and progress value ... i define some control class ..............//// a button click raise the upload if (((StatusFtpUpload)Application["ftpupload"]).Running == false){ ThreadPool.QueueUserWorkItem(new WaitCallback(FtpUpload), ((StatusFtpUpload)Application["cpx_ftpupload"])); }

    // the procedure polled in threadpool that need update the stateInfo.progress value
    static void FtpUpload(Object stateInfo) {

        StatusFtpUpload status = (StatusFtpUpload)stateInfo;
        Rebex.Net.Ftp ftpcontrol = new Rebex.Net.Ftp();


        try {



            ftpcontrol.Connect(status.FtpData.IpServer);
            ftpcontrol.Login(status.FtpData.User, status.FtpData.Password);
            ftpcontrol.PutFiles(status.FtpData.LocalFolder, status.FtpData.RemotePath, FtpBatchTransferOptions.Recursive, FtpActionOnExistingFiles.OverwriteAll);
     //try do someting with events but dont find how control the progress nither value

        }
        finally { 
            status.Running = false; 
        }

asked 20 Apr '10, 15:14

Yonnyy's gravatar image

Yonnyy
161
accept rate: 0%


All you need is to register the Ftp.BatchTransferProgress event and specify appropriate method of your StatusFtpUpload class. You can try something like this:

class StatusFtpUpload {
    // ... add this method to your existing StatusFtpUpload class
    public void BatchTransferProgress(object sender, FtpBatchTransferProgressEventArgs e) {
        // update internal values
        this.progress = e.ProcessedPercentage;
    }
}

// the procedure polled in threadpool that need update the stateInfo.progress value
static void FtpUpload(Object stateInfo) {
    StatusFtpUpload status = (StatusFtpUpload)stateInfo;
    Rebex.Net.Ftp ftpcontrol = new Rebex.Net.Ftp();

    // register status.BatchTransferProgress method
    ftpcontrol.BatchTransferProgress += new FtpBatchTransferProgressEventHandler(status.BatchTransferProgress);

    try {
        ftpcontrol.Connect(status.FtpData.IpServer);
        ftpcontrol.Login(status.FtpData.User, status.FtpData.Password);
        ftpcontrol.PutFiles(status.FtpData.LocalFolder, status.FtpData.RemotePath, FtpBatchTransferOptions.Recursive, FtpActionOnExistingFiles.OverwriteAll);
    }
    finally { 
        status.Running = false; 
    }
link

answered 20 Apr '10, 16:30

Lukas%20Matyska's gravatar image

Lukas Matyska ♦♦
78217
accept rate: 27%

edited 20 Apr '10, 16:42

lukas thanks for answer me ... but status is not a rebex.ftp derived class. i define a method:

    static void progressupdate(object state, FtpBatchTransferProgressEventArgs ev) {

        ((StatusInfo)state).Progress = ev.ProcessedPercentage;

    }

then at method make this that u say:

ftpcontrol.BatchTransferProgress += new FtpBatchTransferProgressEventHandler(progressupdate);

but ... how send parameters?

thanks againg

(21 Apr '10, 15:43) Yonnyy

There is no need for the StatusFtpUpload class to be derived from the Rebex.Net.Ftp class.

You can register ANY method in the Ftp.BatchTransferProgress event (even the method of your class) as shown in my answer.

Just try it ;-)

(21 Apr '10, 15:51) Lukas Matyska ♦♦
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×136
×9
×3
×2

Asked: 20 Apr '10, 15:14

Seen: 1,101 times

Last updated: 20 Apr '10, 16:42