Solved

Client download .csv file from server using Response.TransmitFile

Posted on 2010-09-03
2
384 Views
Last Modified: 2012-05-10
I am using the code below to enable clients to download a .csv file from my server.

The problem I am having is that when the file is saved to the client computer the file name is prefixed and suffixed with an underscore which leads to a file type of .csv_ which is obviously not a recognised file type.

How can I strip the underscores from the file name at the transmit stage?

        Dim FileName As String = LstBox1.SelectedItem.ToString
        Dim FilePath As String = "~/temp" & FileName
        Response.Clear()
        Response.ContentType = "text/csv"
        Response.AddHeader("Content-Disposition", "attachment; filename=\" & FileName & "\")
        Response.TransmitFile(FilePath)
        Response.End()
0
Comment
Question by:taylor99
2 Comments
 
LVL 40

Expert Comment

by:Kyle Abrahams
ID: 33596446
call replace inline on the filename.
Response.AddHeader("Content-Disposition", "attachment; filename=\" & FileName.Replace("_","") & "\")
0
 

Accepted Solution

by:
taylor99 earned 0 total points
ID: 33707245
see http://forums.asp.net/p/1598575/4065473.aspx#4065473 for resolution to this issue
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now