Click here to Skip to main content
15,843,200 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi All,

I am creating windows application with crystal reports. To access the crystal report we have to give full path of the crystal report like below.

C#
cryreport.Load("D:/AddressManagement/Reports/Village.rpt");
crystalReportViewer1.ReportSource = cryreport;
crystalReportViewer1.Refresh();


If we want to give this project to client we also have to give reports to client with exe file.

So i have created Set up and deployment project for this application and i have put all reports in the Application folder of Set up and deployment project.

So my question is that after putting reports in the application folder what path i have to give in
cryreport.Load(..........);

Please any one can help me in this. I need it in urgent.

Thanks and in regards in advance.
Posted
Updated 14-Sep-11 20:35pm
v2
Comments
Prerak Patel 15-Sep-11 1:35am    
Added code block.

These values you can use as to get the root location where the setup in actually being installed and then further sub directories can be added with any of them to locate the folder (same as used in setup project) which contains the .rpt files.

For asp.net application:

HttpContext.Current.Request.ApplicationPath;

For Windows App using VB.Net:

AppDomain.CurrentDomain.BaseDirectory
 
Share this answer
 
Look at below link for details

msdn.microsoft.com/en-us/magazine/cc301570.aspx
 
Share this answer
 
v2
Comments
RaviRanjanKr 17-Sep-11 3:50am    
hey! Rakesh I've just convert Url to Hyperlink. I think you missed it :)
Thanks for all your help.

Finally I got the solution

C#
Application.StartupPath + "\\" + "MyReport.rpt";

VB
Application.StartupPath & "\" & "MyReport.rpt";

Revert back to me if you still find problem.
 
Share this answer
 
You can do this way:

Put all your .rpt files in the debug folder of your application.

And write this in your code:

C#
string paths = Path.GetDirectoryName(Application.ExecutablePath) + ".\\Village.rpt";
            cryreport.Load(paths);


And In setup and deployment put all your .rpt files along with .exe in application folder.

hope it helps :)

for further queries comment here!
 
Share this answer
 
v2

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