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 1045819
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T16:02:44+00:00 2026-05-16T16:02:44+00:00

How can i Make A Text File In Memory(Ram -> Save NoWhere) And Write

  • 0

How can i Make A Text File In Memory(Ram -> Save NoWhere) And Write Something On It And Open NotePad on top of Client browser And Open That Text File In It And Let the user save it by him/her self? -> in code behind

thanks in future advance

best regards

  • 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-16T16:02:45+00:00Added an answer on May 16, 2026 at 4:02 pm

    You can’t do that.
    All you can do is write content of the file to Response with correct MIME type in header (for example “text/plain”) and client browser will open text data with configured viewer for provided MIME type.

    <%@ Page language="vb" runat="server" explicit="true" strict="true" %>
    2   <script language="vb" runat="server">
    3   Sub Page_Load(Sender As Object, E As EventArgs)
    4       Dim strRequest As String = Request.QueryString("file") '-- if something was passed to the file querystring
    5       If strRequest <> "" Then 'get absolute path of the file
    6           Dim path As String = Server.MapPath(strRequest) 'get file object as FileInfo
    7           Dim file As System.IO.FileInfo = New System.IO.FileInfo(path) '-- if the file exists on the server
    8           If file.Exists Then 'set appropriate headers
    9               Response.Clear()
    10              Response.AddHeader("Content-Disposition", "attachment; filename=" & file.Name) ' comment this line if needed
    11              Response.AddHeader("Content-Length", file.Length.ToString())
    12              Response.ContentType = "application/octet-stream" 'this is MIME type
    13              Response.WriteFile(file.FullName)
    14              Response.End 'if file does not exist
    15          Else
    16              Response.Write("This file does not exist.")
    17          End If 'nothing in the URL as HTTP GET
    18      Else
    19          Response.Write("Please provide a file to download.")
    20      End If
    21  End Sub
    22  </script>
    

    http://www.xefteri.com/articles/show.cfm?id=8

    Here is slightly modified c# sample code

    <%@ Page Title="Home Page" Language="C#" AutoEventWireup="true"%>
    <script language="cs" runat="server">
        public void Page_Load(object sender, EventArgs e)
        {
    
            byte[] buffer;
            using (var memoryStream = new System.IO.MemoryStream())
            {
                buffer = Encoding.Default.GetBytes("Hello StackOverflow"); //Dummy data
                memoryStream.Write(buffer, 0, buffer.Length);
                Response.Clear();
                Response.AddHeader("Content-Disposition", "attachment; filename=hello.txt"); //This wil force browser to silently download file. you can comment this line to see difference
                Response.AddHeader("Content-Length", memoryStream.Length.ToString());
                Response.ContentType = "text/plain"; //This is MIME type
                memoryStream.WriteTo(Response.OutputStream);
            }
            Response.End();
    
        }
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I can make my program write a .dat file with an array of Node
is there any way out that we can make the data in text file
I am trying to make a text file in memory, add some lines to
In QMessageBox how can I make the title text bold? Here is the sample
In MS Visual Studio, you can hold down the Alt key and make text
How can I make my strings and text attributes bold in my actionscript code?
How can I make a list with pictures and summary (the text under the
How can I make my <div> elements grow (and the content changes text size
In the following case, how can I make it such that the text generated
I know I can use placeholder=some text here... but how to make it so

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.