Hi,
I created a web API and one WPF application I need to send one excel file from WPF application to the service through Web API.
which is the best way to do that?
Thanks in advance.
Rajavel Ramabalan.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
Salman BegRank #284 · 8.8K reputationPosted Apr 3, 2019, 12:52 AM EDT
Bidyasagar MishraRank #766 · 3K reputationPosted Aug 16, 2019, 5:06 PM EDT
public HttpResponseMessage Post() { var httpRequest = HttpContext.Current.Request; if (httpRequest.Files.Count { return Request.CreateResponse(HttpStatusCode.BadRequest); } foreach(string file in httpRequest.Files) { var postedFile = httpRequest.Files[file]; var filePath = HttpContext.Current.Server.MapPath("~/" + postedFile.FileName); postedFile.SaveAs(filePath); // NOTE: To store in memory use postedFile.InputStream } return Request.CreateResponse(HttpStatusCode.Created); }