I'm using Webclient to try and send my image I've got on my winform application to a central server. However I've never used WebClient before and I'm pretty sure what I'm doing is wrong.
First of all, I'm storing and displaying my image on my form like so:
_screenCap = new ScreenCapture();
_screenCap.OnUpdateStatus += _screen_CapOnUpdateStatus;
capturedImage = imjObj;
imagePreview.Image = capturedImage;
I've set up an event manager to update my imagePreview image when ever I take a screenshot. Then displaying it when ever the status changes like this:
private void _screen_CapOnUpdateStatus(object sender, ProgressEventArgs e)
{
imagePreview.Image = e.CapturedImage;
}
With this image I'm trying to pass it to my server like so:
using (var wc = new WebClient())
{
wc.UploadData("http://filelocation.com/uploadimage.html", "POST", imagePreview.Image);
}
I know I should convert the image to a byte[] but I've no idea how to do that. Could someone please point me in the right direction of go about doing this properly?