title: How to download a file in ASP.NET MVC using C#?
body: <p>I'm working on an assignment, and I'm stuck in downloading section. I can upload the file. But when I'm trying to download the same file after uploading, I get an error ("Access is denied"). </p>
  
  <p>Here is the code which I have written:</p>
  
  <pre><code>[HttpGet]
  public FileResult Download (string fileName)
  {
      var permissionSet = new PermissionSet(PermissionState.None);
  
      var writePermission = new FileIOPermission(FileIOPermissionAccess.Write, @"D:\Assignment\Ment\Ment\Photos");
      permissionSet.AddPermission(writePermission);
  
      var FileVirtualPath = Server.MapPath("~/Photos/" + fileName); //"~/Photos/" + fileName;
  
      return new FilePathResult(@"D:\Assignment\Ment\Ment\Photos", "application/octet-stream");
  }
  </code></pre>