Click here to Skip to main content
15,892,737 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
In the following code I get an error stating: 'The name 'Path' does not exist in the
current context' at line- string filePath=Path.Combine(..


C#
public Form5()
       {
           InitializeComponent();
           ReportDocument reportDocument = new ReportDocument();
           string filePath = Path.Combine(Application.StartupPath, "CrystalReport11.rpt"); //report file name .rpt
           reportDocument.Load(filePath);
           crystalReportViewer1.ReportSource = reportDocument;
       }

       private void dynamicreporttest_Load(object sender, EventArgs e)
       {
           this.crystalReportViewer1.RefreshReport(); // report viewer file name is crystalReportViewer1
       }
Posted
Comments
S.Rajendran from Coimbatore 17-May-14 6:51am    
i dont see the answer!!

1 solution

Hi...
Just give like below!
C#
string filePath = Path.Combine(Application.StartupPath, "/Project_name/Folder_name/CrystalReport11.rpt");

Thank u. Its work for me.
 
Share this answer
 
Comments
S.Rajendran from Coimbatore 17-May-14 7:23am    
I tried.Same error comes.
S.Rajendran from Coimbatore 18-May-14 0:55am    
It works. Earlier I did not include the project name. Well. Thank you.
AT the same time if I wanted to show the report from another file say 'CrystalReport10.rpt' the result is that it shows the same report of 'CrystalReport11.rpt"!. Ofcourse in the path I have mentioned the file name as 'CrystalReport10.rpt'. Why is it so?
The code:
string filePath = Path.Combine(Application.StartupPath, "/WindowsFormsToSqlTest/WindowsFormsToSqlTest/CrystalReport10.rpt");
reportDocument.Load(filePath);
crystalReportViewer1.ReportSource = reportDocument;

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900