Skip to content

Instantly share code, notes, and snippets.

@mps
Created June 7, 2012 17:03
Show Gist options
  • Save mps/2890074 to your computer and use it in GitHub Desktop.
Save mps/2890074 to your computer and use it in GitHub Desktop.
Mono File Upload
public void UploadFile ()
{
var uri = new Uri ("http://my_file_upload_handler.com");
var client = new WebClient ();
client.UploadFileCompleted += UploadComplete;
client.UploadFileAsync(uri, "local_file.png");
}
public void UploadComplete (object sender, UploadFileCompletedEventArgs args)
{
// Handle the completed event to display success or error on upload to the user.
var message = "Upload Complete!";
if (args.Error != null) {
message = "Upload Failed, try again!";
// Maybe log the error somewhere for future debugging
}
// Show an error or success alert to the user.
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment