• 0

[C#] WebClient method


Question

I have a webclient instance that uploads a file. I wanted to upload it using WebClient.UploadFile but that locks the thread up until it's done uploading it and has no way of me showing the progress of it. Any ideas how to turn this code into async code?

private void upl_fns(object sender, EventArgs e)
		{
			progressBar1.Value = 1;
			string newFile = gl_filepath.LastIndexOf(@"\").ToString();
			Uri uri1 = new Uri("ftp://ftp.couchpotatoheroes.com/public_html/" + newFile.ToString());
			uplFile.Credentials = new NetworkCredential("couchpo1@couchpotatoheroes.com", "sr12m12sr");
			uplFile.UploadFile(uri1, gl_filepath);
			//MessageBox.Show(responseArray.ToString());
			//progressBar1.Value = 100;
		}

		private void UploadProgressCallback(object sender, UploadProgressChangedEventArgs e)
		{
			progressBar1.Value = e.ProgressPercentage;
		}

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.