Hi All,
I'm trying to create an app that can upload the same file to multiple site at the same time.
This is my code till now...
The Code that triggers the upload routine (UploadFile) is:
When SiteList is a listView with the sites IPs and txtURL is the path of the file to upload.
now the function seems to work find, but I can't seem to find a way to update each Item in the ListView with the status (upload %, fail, success and etc..)
Is there any way so that the Upload % (as done in UploadProgress) can be "linked" to the site / index of the listView so I will know who assign the response to the correct site
Thanks in advance for the Help.
I'm trying to create an app that can upload the same file to multiple site at the same time.
This is my code till now...
Code:
private void UploadFile(string _ip, string _file)
{
//Setup the client and Credentials
WebClient wc = new WebClient();
wc.Credentials = new NetworkCredential("user", "pass");
//set the Async routines
wc.UploadFileCompleted += new UploadFileCompletedEventHandler(UploadFileDone);
wc.UploadProgressChanged += new UploadProgressChangedEventHandler(UploadProgress);
wc.UploadFileAsync(new Uri("http://" + _ip + DBPath), "POST", _file);
}
void UploadFileDone(object sender, UploadFileCompletedEventArgs e)
{
textBox1.Text = System.Text.Encoding.UTF8.GetString(e.Result);
}
void UploadProgress(object sender, UploadProgressChangedEventArgs e)
{
textBox1.Text = (string)e.UserState + "\n\n"
+ "Uploaded: " + e.BytesSent + "/" + e.TotalBytesToSend;
}
The Code that triggers the upload routine (UploadFile) is:
Code:
private void btn_Start_Click(object sender, EventArgs e)
{
for (int i = 0; i < SiteList.Items.Count; i++)
{
UploadFile(SiteList.Items[i].Text, txtURL.Text);
}
}
now the function seems to work find, but I can't seem to find a way to update each Item in the ListView with the status (upload %, fail, success and etc..)
Is there any way so that the Upload % (as done in UploadProgress) can be "linked" to the site / index of the listView so I will know who assign the response to the correct site
Thanks in advance for the Help.