.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Client download .csv file from server using Response.TransmitFile

Posted By:      Posted Date: September 04, 2010    Points: 0   Category :ASP.Net
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() 

View Complete Post

More Related Resource Links

Download an XML File to the IIS server, not to the client


Hey guys,

I'm trying to do the following in ASP.NET (with c#):

1. On page Load, download an XML file from a different website to the IIS server, in a subdirectory of the application directory called "downloadedFiles"

I know that WebClient.DownloadFile() can download a file, but this only seems to download the file to the client's machine. I am interested in downloading it to the actual IIS server (so that it can be utilized throughout the lifetime of more than one session). Does anyone know how this could be performed?

Specifically, I'm trying to download an XML file from a website (as an example: http://api.twitter.com/1/statuses/followers/CiscoSystems.xml). How could I download that XML file onto my actual IIS server?

Thanks a ton for any help

Problem download file from SQL Server


Hello everyone. I am having an issue downloading files that I have store in SQL Server. I have no problem in a WinForm. What am I doing wrong in my code?

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        Dim sch As New clsReport
        Dim fileData As New clsReport.Letter
        fileData = sch.DownloadLetter(Session("LetterID"))
        Dim ms As System.IO.MemoryStream = fileData.fil

        Dim fil As Byte() = ms.ToArray
        Dim nam As String = fileData.name
        Dim ext As String = fileData.ext
        If Not fil Is Nothing Then
                ' Response.Clear()
                Response.AppendHeader("Content-Disposition", "attachment; filename=" + nam & "." & ext)
                ' Response.AddHeader("Content-Disposition", nam & "." & ext)
                Response.AddHeader("Content-Length", fil.Length.ToString)
                Response.ContentType = "Application/octet-stream"
                Response.Buffer = True
            Catch ex As Exception
            End Try

        End If

    End Su

Saving Image File in a Folder on Sever from Client Machine using Sql Server

  Hi EveryOne... Can anyone help me Saving an Image file in a Server folder from a client machine using Sql server 2005....   

Force File Download on a Remote File Server

Hi!I'm trying to force a large (200+ MB) file to download that's on a remote server. The problem is that I can't use the "WriteFile()" function, since I'm not using a virtual path.Then, when I try:Response.AppendHeader("content-disposition",                 "attachment; filename=" + name);Response.AppendHeader("content-disposition", "attachment; filename=" + name);I get a file that has the correct name and extension, but is 0KB. Can someone please help me?!Thanks!-Eric

Urgent!!!!!!!-- xecuting Server Side .exe File From Client Side

helllocan any 1 plz teel me . How To run exe on client machine which(exe) store in Server side.I dont want user need to downoad My .exe file and then Install on his machine. I want user just click on Register linkbutton and directly Start Executable Installation process. PLZ HELP MEAMIT:)

Download .xlsx file from server

Hi, Iv created a web application using vb.net 2005. Its working fine and running fine on the server (Microsoft Server 2003). The problem i have is to dowload a file from the same server using vb.net. I tried using this code but it gives me a : "is not a virtual path" error. Response.ContentType = "file/xlsx" Response.AppendHeader( Response.TransmitFile( Response.End()"Content-Disposition", "attachment; filename=AllReports.xlsx")".xlsx") Please help, im way overdue with this. Thank.

run dtexec on server from batch file on client machine

Hi I would like to enable a user to execute an SSIS (2005) package located on a server.  The client does not have any elements of SQL server installed on his machine so he cannot execute the package locally.  At present he has to remote connect to the server and double click a batch file on the server that contains the dtexec script. I would like to have a batch file located on the client desktop that he can click, that will run the dtsexec script on the server - as it will not work from the client machine.  However every set of commands i try inevitably end up trying to run the package on the local machine, which obviously fails. Is there any way to have the client kick of the package and have it run on the server, without him actually having to directly remote desktop to the client? Thanks  Guy

how to set a client folder to get upload and download the file.


i create a web site for uploading and download but i require that a folder create in client side if client download the file these file automatically save 

Download a file then either redirect or refresh the page (after response.end)??


Hi all,

I am using some code similar to the code below to open a word document on my ASP.net app.  Once the file has been downloaded and opened I then want to either redirect to another page or refresh the screen but nothing works after response.end and if i add it before response.end the browser never downloads the file?

Response.AddHeader("Content-Disposition", "attachment; filename=" + file.Name                  
Response.AddHeader("Content-Length", file.Length.ToString());
Response.ContentType = "application/octet-stream";

Any ideas?  Thanks

How can I download an Excel file saved on the same server as an asp.Net website?



I able to successfully see all the Excel files in the given folder using the datagrid and code below. Now I would like to be able to click the link to the file, or add a button, to get a download file dialog box. Can someone please help me.



<asp:datagrid id="FileGrid" runat="server" 
    AutoGenerateColumns="False" AllowSorting="True">
        <asp:TemplateColumn HeaderText="File" >
                <asp:HyperLink id="systemLink" runat="server" 
                NavigateUrl='<%# DataBinder.Eval(Container, "DataItem") %>'
                Text='<%# DataBinder.Eval(Container, "DataItem") %>' />
        <asp:BoundColumn DataField="Length" HeaderText="File Size" />
        <asp:BoundColumn DataField="LastWriteTime" HeaderText="Last Modified" />


Imports System.IO

Partial Class pageclass

Download audio file from server


string url = string.Empty;

string title = string.Empty;

//full file path should be assigned to url

//file name with format should be assigned to title    

url = "http://abc.com/abc.mp3";     

title = "abc.mp3.mp3";

WebClient wc = new WebClient();
byte[] byteData;
Response.BinaryWrite(byteData= wc.DownloadData(@url));

File corrupt issue with SQL Server Express 2008 Download

I have tried to download SQL Server Express 2008 with advanced services a several times from different locations across the MS web site.  I keep getting a File Corrupt error when extracting "owc11sp1.msp."  I have tried several different computers and following the steps directly.  I can not perform a web install on the machine that will host the SQL server, so that option is out.  Does anyone know where I can get a copy of this that actually works?

I tried downloading it from here:

scripts file not found on server - 404


Fiddler is showing a 404 error when my published web application runs. the jquery.js file in
/scripts is highlighted in red by fiddler as not found. ( IIS log also shows the 404 error ).
I run the web app from visual studio, on local host - no problems. The publish is successful.
All the files are in the scripts folder of the web app on the server.

In the site.master I have:
<script src="../../Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>

Visual studio does not complain about this. ( which indicates the file is found. )

Oddly, when I fully qualify the path, VS says file not found, but after I publish and run, fiddler
shows the jquery file being found and sent to the browser.
<script src="/MvcApplication1/Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>

when the <script> path is "../../Scripts/jquery-1.4.1.min.js", the fiddler error is
404: /Scripts/jquery-1.4.1.min.js .

when the <script> path is "/MvcApplication1/Scripts/jquery-1.4.1.min.js", fiddler shows the file
being sent to the browser from that /MvcApplication1/Scripts path.

Both the Scripts fol

how to know when a user finish his file download successfully ?


hi all

i am doing a page to sell files online

 the paying method is by a card or bank account and the customer is not registered to the site so i want to make sure that the customer has downloaded the file successfully after that the system completes the payment operation

so if there is any way to know do that tell me please

i use c# thanx all



Talk Back: Voice Response Workflows with Speech Server 2007


Speech Server 2007 lets you create sophisticated voice-response applications with Microsoft .NET Framework and Visual Studio tool integration. Here's how.

Michael Dunn

MSDN Magazine April 2008

ClickOnce: Deploy and Update Your Smart Client Projects Using a Central Server


ClickOnce is a new deployment technology that allows users to download and execute Windows-based client applications over the Web, a network share, or from a local disk. Users get the rich interactive and stateful experience of Windows Forms, but still have the ease of deployment and updates available to Web applications. ClickOnce applications can be run offline and support a variety of automatic and manual update scenarios.Learn all about it here.

Brian Noyes

MSDN Magazine May 2004

SOAP: Using ATL Server to Build an Asynchronous SOAP Client in Unmanaged C++


SOAP opens up a new world of Web Services, letting you make function calls across a network or the Internet. But this flexibility creates new problems when your app needs to wait for calls to return from halfway around the world. What you need is an asynchronous SOAP client that takes advantage of threading to continue execution while waiting for calls over the wire. This article covers the basics of building such a client with ATL.

Pranish Kumar and Bogdan Crivat

MSDN Magazine April 2002

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend