I'm performing upload in class manner.
From main class i'm calling openload class to provide File location. In openload upload class i check authentication and gets upload adress and send that upload adress to another class named Upload which performs multipart/form-data upload.
Everything is working fine without using progress bar. But i want to implement progress bar to run sucessfully.
I'm using backgroundworker in my main class to call openload function and provide file location.
Expand|Select|Wrap|Line Numbers
- private void BackgroundWorker_DoWork(object sender, DoWorkEventArgs e)
- {
- if (!string.IsNullOrEmpty(File))
- {
- var Link = new FileHost.Openload();
- OutputBox.Text = Link.Upload(File);
- }
- }
Expand|Select|Wrap|Line Numbers
- Upload Upload = new FileHost.Upload();
- Thread Uploading = new Thread(() =>
- {
- UploadResult = Upload.UploadFilesToRemoteUrl(UploadURL, FileName, null);
- });
- Uploading.Start();
Expand|Select|Wrap|Line Numbers
- using (var fileStream = new FileStream(file, FileMode.Open, FileAccess.Read))
- {
- var buffer = new byte[1024];
- int totalReadBytesCount = 0;
- var bytesRead = 0;
- while ((bytesRead = fileStream.Read(buffer, 0, buffer.Length)) != 0)
- {
- memStream.Write(buffer, 0, bytesRead);
- totalReadBytesCount += bytesRead;
- var progress = totalReadBytesCount * 100.0 / fileStream.Length;
- }
- }
but i can't call main class backgroundworker to working class i.e. upload class.
is there any method or delegate to call backgroundworker of main class in another class.