private void button1_Click(object sender, EventArgs e) { using (localhost.ImagingServicesContractSoapClient m_proxy = new ImagingServicesContractSoapClient()) { System.IO.MemoryStream stm = null; try { if (this.pic.Image == null) { throw new InvalidOperationException("Please select an image to upload!"); } ImageInfo imgInfo = new ImageInfo(); imgInfo.Category = "Image"; imgInfo.DateStart= System.DateTime.Now; imgInfo.DateEnd= null; imgInfo.Title= this.labFilename.Text; imgInfo.Url= this.labFilename.Text; using (stm = new System.IO.MemoryStream()) { this.pic.Image.Save(stm, this.pic.Image.RawFormat); byte[] data = new byte[stm.Length]; data = stm.ToArray(); imgInfo.Data= data; } m_proxy.UploadImage(imgInfo); MessageBox.Show("File uploaded!"); } catch (UserCancellationException exUserCancelled) { MessageBox.Show(exUserCancelled.Message); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } }
private void button1_Click(object sender, EventArgs e) { using (localhost.ImagingServicesContractSoapClient m_proxy = new ImagingServicesContractSoapClient()) { System.IO.MemoryStream stm = null; try { if (this.pic.Image == null) { throw new InvalidOperationException("Please select an image to upload!"); } ImageInfo imgInfo = new ImageInfo(); imgInfo.Category = "Image"; imgInfo.DateStart = System.DateTime.Now; imgInfo.DateEnd = null; imgInfo.Title = this.labFilename.Text; imgInfo.Url = this.labFilename.Text; using (stm = new System.IO.MemoryStream()) { this.pic.Image.Save(stm, this.pic.Image.RawFormat); byte[] data = new byte[stm.Length]; data = stm.ToArray(); imgInfo.Data = data; } m_proxy.UploadImage(imgInfo); MessageBox.Show("File uploaded!"); } catch (UserCancellationException exUserCancelled) { MessageBox.Show(exUserCancelled.Message); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } }