TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Shawn ORourke
NA
2
0
CSV Download from a Web App
May 3 2006 2:46 PM
First, Thanks for any assistance I receive.
I have a Dataset that I am using to populate a .CSV file and provide the ability for the end user to 'download' the resulting file. I am populating the dataset and populating a DataTable with it. I am then creating the Folder and File with the extension '.CSV'. I then populate the file row by row using a string. The file is in the correct location, format (.CSV) and properly populated at this point.
I then call a function that I have attempted to allow the user to download the file. I have attempted this in several different fashions using the Response object. All attempts are downloaded without the .CSV extension. I have pasted some of the code to preform this function below. I do trap an error that states "Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack". I have 'Googled' this error and modified my VS Options>Debugging>Just-in-Time to all the Debug in mixed mode (Managed and Native). The error occurs when I step through the code at the Response.End
I have attempted this with the
HtmlTextWriter, StringWriter, StreamWriter and StringBuilder all with the same result.
Can someone assist?
string strFileNameCSV = "C:\\ExportReports\\Export_CSV_" + ReportForm1.strUserID + ".csv";
//FileInfo fiBPM_Export = new FileInfo(strFileNameCSV);
//Clear Headers
Response.Clear();
Response.ClearHeaders();
//set the conttent type of the file to be downloaded
Response.ContentType = "text/comma-separated-values";
// initialize the http content-disposition header to indicate a file attachment with the filename
Response.AppendHeader("Content-Disposition", "Attachment; Filename=\"" + strFileNameCSV + "\"");
////// transfer the file byte-by-byte to the response object
//FileInfo fileToDownload = new FileInfo(strFileNameCSV);
//Response.Flush();
//Response.WriteFile(fileToDownload.FullName);
Response.WriteFile(strFileNameCSV);
//Response.TransmitFile(strFileNameCSV);
//Response.Redirect(strFileNameCSV);
Response.End();
Reply
Answers (
0
)
iframe with the server control
How can I set a value in a cell of the DataGridView that contains a DataGridViewComboBoxColumn?