Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET
Hello Everyone,
 
I want to Generate and Save a Crystal Report based on user selections file Format(from Drop down list.
 
Dim filename As String = ds.Tables(0).Rows(0)("reportoutfile")
Response.ContentType = "applicaiton/octet-stream"
Response.WriteFile(??)
 

Line 1: reportoutfile is Parameter having File name.
Line 3: What will be the parameter of Response.WriteFile?

And where should be path of my report?
Posted 20-Feb-13 0:31am

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Generally if any file need to download the following code can do that
    string file_path=Server.MapPath("~/files/"+file_name); 
    HttpContext.Current.Response.ContentType = "application/octet-stream";
    HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment;filename=\"" + file_Name + "\"");
    HttpContext.Current.Response.TransmitFile(file_path);        
    HttpContext.Current.Response.End();
 
For crystal report I guess you need to take help of Crystal Report viewer control to create crystal report file.
  Permalink  
Comments
Vardhan Desai at 20-Feb-13 23:43pm
   
Still i m getting same error as FileNotFoundException
S. M. Ahasan Habib at 21-Feb-13 0:37am
   
FileNotFoundException raised when file not found to a specific location. So I guess your file_path value is wrong. You just debug the code and see the value of file_path and find out that the file physically exists in this location (file_path).

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 555
1 Sergey Alexandrovich Kryukov 518
2 CPallini 490
3 George Jonsson 231
4 Afzaal Ahmad Zeeshan 194
0 OriginalGriff 5,450
1 CPallini 4,500
2 Sergey Alexandrovich Kryukov 4,032
3 George Jonsson 3,057
4 Gihan Liyanage 2,445


Advertise | Privacy | Mobile
Web02 | 2.8.140916.1 | Last Updated 20 Feb 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100