title: Using same method to download different file
body: <p>I'm currently working on an web app which I'm using C# and Asp.Net MVC. On one of the page I have a requirement where users are able to download files and fill in the relevant data then upload them. Due to some users having old machine I'm working with <code>.xls</code> and <code>.xlsx</code>. Which file can be downloaded is based upon a dropdown value which a user must select. </p>
  
  <p>I have two buttons one for <code>.xls</code> and one for <code>xlsx</code> file. My question is how can I use the same backend code to swap between the files. So if <code>.xls</code> is clicked the user gets the <code>.xls</code> file and if the other is click then they receive <code>.xlsx</code> file.</p>
  
  <p>This is my code so far:</p>
  
  <pre><code>public FileResult DownloadTemplates(string policyType)
  {
     string templateName = string.Empty;
     string baseDirectory = "base path";
     string templateDirectory = "temnplate directory path";
  
      switch (policyType)
      {
         case "Administrative":
            templateName = "Admin Xls File"; //How can I swap between the .xls and .xlsx file?
            break;
         case "Policy":
            templateName = "Policy Xls File"; //How can I swap between the .xls and .xlsx file?
            break;
         case "Consignment":
            templateName = "Consignment Xls File"; //How can I swap between the .xls and .xlsx file?
            break;
         case "Quality":
            templateName = "Quality Xls file"; //How can I swap between the .xls and .xlsx file?
            break;
         default:
            templateName = string.Empty;
            break;
      }
  
      string filePath = Path.Combine(baseDirectory, templateDirectory, templateName);
      byte[] fileData = System.IO.File.ReadAllBytes(filePath);
      string contentType = MimeMapping.GetMimeMapping(filePath);
  
      return File(fileData, contentType);
  }
  </code></pre>