public void UploadPhoto(PhotoLink fileInfo, byte[] fileData) { using (PhotoUploadContractClient proxy = new PhotoUploadContractClient()) { proxy.UploadPhoto(fileInfo, fileData); } }
private void cmdSave_Click(object sender, EventArgs e) { try { PhotoLink fileInfo = new PhotoLink(); fileInfo.Title = this.txtTitle.Text; fileInfo.Description = this.txtDescription.Text; fileInfo.DateStart = this.dtpStart.Value; fileInfo.Url = this.txtUrl.Text; fileInfo.Category = "General"; MemoryStream stm = new MemoryStream(); this.pic.Image.Save(stm, this.pic.Image.RawFormat); byte[] fileData = new byte[stm.Length]; fileData = stm.ToArray(); m_proxy.UploadPhoto(fileInfo, fileData); MessageBox.Show("File uploaded!"); } catch (Exception ex) { string s = String.Format("{0}\r\nERROR:{1}", ex.GetType(), ex.Message); MessageBox.Show(s); } }