Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

592
Views
Download file to browser from SFTP server in ASP.NET using SSH.NET

With SSH.NET, I am trying to trigger a file to be downloaded by the browser instead of directly writing it to the local file storage.

using(var saveFile = File.OpenWrite(@"Downloads")) {
  result = client.BeginDownloadFile(remotePath + fileName, saveFile) as SftpUploadAsyncResult;

  client.EndUploadFile(result);
}

The above code fails as my the application pool identity doesn't have permission to write files and I cannot give permission as I don't have Admin privileges to my computer.

So better option would be to trigger the download through browser which was working earlier with FtpWebRequest.

But my current task is to convert the FTP download to SFTP download.

Can someone suggest the best way to trigger browser download?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Download the file to HttpResponse.OutputStream:

HttpResponse response = HttpContext.Current.Response;

response.AddHeader("Content-Disposition", "attachment;filename=" + fileName);

client.DownloadFile(remotePath + fileName, response.OutputStream);
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!