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

  • Home
  • SEARCH
  • 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 7637189
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T07:52:34+00:00 2026-05-31T07:52:34+00:00

I’ve got a simple web-page that generates a CSV file that I want the

  • 0

I’ve got a simple web-page that generates a CSV file that I want the user to be able to download once its creation is complete.

Here’s a summary of my situation:

  1. The CSV file can be created in-memory or on disk. Doesn’t matter to me.
  2. Once I’m done transmitting the CSV file, I do not want it to continue residing on disk.
  3. I’ve tried various code using Response.WriteFile, .TransmitFile, .BinaryWrite and .Write, but to no avail.
  4. When I say “to no avail”, I mean that rather than the CSV file being transmitted, I’m transmitting the contents of the CSV file PLUS THE ENTIRETY OF THE CURRENT PAGE!
  5. I’m really confused since I have another page that’s doing essentially the same thing, but with PDF files bundled in a zip file, and it works just fine.
  6. I’m really a Windows desktop developer, but I’m trying to become a web developer. (So sorry if this is a stupid or noob question.)

Here’s the code I’ve got working to send the .zip containing PDF files:

Protected Sub SaveReportsButton_Click(sender As Object, e As EventArgs) Handles SaveReportsButton.Click
    '' The .zip file is created elsewhere
    Dim fullPath As String = Server.MapPath("~/Reports/" & Session.SessionID & ".zip")
    Response.ContentType = "APPLICATION/OCTET-STREAM"
    Dim fileToDownload As New FileInfo(fullPath)
    Dim disHeader As String = "Attachment; Filename=""Reports.zip"""
    Response.AppendHeader("Content-Disposition", disHeader)
    Response.Flush()
    Response.WriteFile(fileToDownload.FullName)
End Sub

Here’s the code I’m trying to get working to transmit the CSV file:

Protected Sub saveButton_Click(sender As Object, e As System.EventArgs) Handles SaveOutput.Click
    Dim list As List(Of String) = {"000000000", "000000000", "000000000"}.ToList()
    Dim sb As New Text.StringBuilder
    For i As Integer = 0 To list.Count - 1
        Dim str As String = list(i)
        sb.Append(str)
        If i < list.Count - 1 Then
            sb.Append(",")
        End If
    Next
    Dim dirPath As String = Server.MapPath("~/Output/" & Session.SessionID)
    IO.Directory.CreateDirectory(dirPath)
    Dim filePath As String = Server.MapPath("~/Output/" & Session.SessionID & "/Output.csv")
    IO.File.WriteAllText(filePath, sb.ToString())
    Response.ContentType = "text/csv"
    Dim disHeader As String = "Attachment; Filename=""Output.csv"""
    Response.AppendHeader("Content-Disposition", disHeader)
    Response.Flush()
    Response.WriteFile(filePath)
End Sub

Like I said, I wish to limit the files created and left on the server by this page, so I’d like to get rid of the CSV file once I’m done with it.

Any help?

Thanks!!!

  • 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-31T07:52:35+00:00Added an answer on May 31, 2026 at 7:52 am

    try this with Response.Write and Response.End

    Protected Sub saveButton_Click(sender As Object, e As System.EventArgs) Handles SaveOutput.Click
        Dim list As List(Of String) = {"000000000", "000000000", "000000000"}.ToList()
        Dim sb As New Text.StringBuilder
        For i As Integer = 0 To list.Count - 1
            Dim str As String = list(i)
            sb.Append(str)
            If i < list.Count - 1 Then
                sb.Append(",")
            End If
        Next
        Response.Clear()
        Response.ContentType = "text/csv"
        Dim disHeader As String = "Attachment; Filename=""Output.csv"""
        Response.AppendHeader("Content-Disposition", disHeader)
        Response.Flush()
        Response.Write(sb.ToString())
        Response.End()
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I've got a string that has curly quotes in it. I'd like to replace
Seemingly simple, but I cannot find anything relevant on the web. What is the
I have a French site that I want to parse, but am running into
I want use html5's new tag to play a wav file (currently only supported
I am doing a simple coin flipping experiment for class that involves flipping a
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
i want to parse a xhtml file and display in UITableView. what is the
I'm making a simple page using Google Maps API 3. My first. One marker

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.