Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7038673
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:41:50+00:00 2026-05-28T01:41:50+00:00

I have a formed file in some folder on server. I need to create

  • 0

I have a formed file in some folder on server. I need to create some solution to allow user save this file local on drive on computer.

Can anyone advice me how it can be done, what control I should use.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T01:41:51+00:00Added an answer on May 28, 2026 at 1:41 am

    This will open the Browser SaveAs dialog:

     protected void Page_Load(object sender, EventArgs e)
    {  
    
        FileStream fs = File.OpenRead(Server.MapPath("~/imgName.jpg"));
        byte[] buffer = new byte[(int)fs.Length];
        fs.Read(buffer, 0, (int)fs.Length);
        fs.Close();
        SetResponse("imgName");
        HttpContext.Current.Response.BinaryWrite(buffer);
        HttpContext.Current.Response.Flush();
        HttpContext.Current.Response.Close();
    }
    
    private static void SetResponse(string fileName)
    {
        string attachment = "attachment; filename=" + fileName + ".jpg";
        HttpContext.Current.Response.Clear();
        HttpContext.Current.Response.ClearHeaders();
        HttpContext.Current.Response.ClearContent();
        HttpContext.Current.Response.AddHeader("content-disposition", attachment);
        HttpContext.Current.Response.ContentType = "image/jpeg";
        HttpContext.Current.Response.AddHeader("Pragma", "public");
    }
    

    try opening the FileStream with this permissions:

      FileStream fs = new FileStream(Server.MapPath("~/imgName.jpg"), FileMode.Open, FileAccess.Read, FileShare.Read);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on this app to gather some file/folder usage data. The goal is
i have a c-file containing some dbus stuff and implementing the dbus.h. this is
I have some non well-formed xml (HTML) data in JAVA, I used JAXP Dom,
I have different php output in jQuery-based tabs. This output is formed from database
I have some non English characters being stored in my web.config file. I am
I'm using Ruby's CSV library to parse some CSV. I have a seemingly well-formed
I have some xml that looks like this: <rootElement attribute=' > '/> This is
I have an application that uses html5 to let the user listen to some
I have a HTML file and I need to display it in JTextPane .
I have a PHP app that creates a CSV file which is forced to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.