title: Asp .net Web API file type
body: <p>I am getting imported file to Web API. </p>
  
  <p>1) How do I identify File Type csv or excel or pdf file.</p>
  
  <p>2) I want to save file On specific folder with User provided File name how can I  achieve that.</p>
  
  <pre><code> [HttpPost]
      public async Task&lt;IHttpActionResult&gt; UploadData()
      {
  
              if (!Request.Content.IsMimeMultipartContent())
              {
                  throw new HttpResponseException(HttpStatusCode.UnsupportedMediaType);
              }
  
                foreach (MultipartFileData file in provider.FileData)
                  {
                      File.Move(file.LocalFileName, filePath);
                      break;
                  }
                  File.Delete(provider.FileData[1].LocalFileName);
     }
  </code></pre>