title: How to download a file containing ampersand?
body: <p>I am having trouble with downloading the files with filenames containing ampersand in C#. I am using HTML download attribute and there are many files which contain an ampersand in a filename. Are there any options to download files with filename containing ampersand with download attribute in HTML?</p>
  
  <p>I have tried using WebClient as well as other methods for downloading the file and I need to have the file downloaded as we download a file from the internet in the browser.</p>
  
  <pre><code>&lt;a href="{{items.FilePath}}{{items.FileName}}" data-toggle="tooltip" 
  data-placement="top" title="{{items.FileName}}" download&gt; &lt;/a&gt;
  
  using (WebClient client = new WebClient())
  {
  client.DownloadFile(paths,@"c:\Users\Jon\Test\foo.txt");
  }
  public HttpResponseMessage DownloadFile(string filePath, string fileName)
  {
  string paths = HttpContext.Current.Server.MapPath(filePath+ fileName);
          var fileBytes = File.ReadAllBytes(paths);
          var fileMemStream = new MemoryStream(fileBytes);
          result.Content = new StreamContent(fileMemStream);
          var headers = result.Content.Headers;
          headers.ContentDisposition = new 
   System.Net.Http.Headers.ContentDispositionHeaderValue("attachment");
          headers.ContentDisposition.FileName = fileName;
          headers.ContentType = new 
   System.Net.Http.Headers.MediaTypeHeaderValue("application/octet- 
    stream");
          headers.ContentLength = fileMemStream.Length;
          return result;
      }
  </code></pre>