public string UploadAttachment(byte[] bytes) { MemoryStream stream = new MemoryStream(bytes); Attachment attachment = Communicator.ParseResponse <Attachment>(stream); System.IO.FileStream file = System.IO.File.Create(HttpContext.Current.Server.MapPath("~/Attachments/" + attachment.FileName + ".jpg ")); file.Write(attachment.File, 0, attachment.File.Length); file.Close(); /*HttpPostedFileBase objFile = (HttpPostedFileBase)new MemoryPostedFile(attachment.File); * Path.GetFileName(objFile.FileName); * var path = Path.Combine(HttpContext.Current.Server.MapPath("~/Attachments/"), attachment.FileName + ".Jpg"); * objFile.SaveAs(path);*/ _sqlProvider.AddAttachmentId(attachment); return("Added."); }