Click here to Skip to main content
15,890,438 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
using ms vsstudio 2010 (c#)..

i hv a folder named "report" in project. it contains all the crystal reports (5 report files) of my project. so if i want to transfer my project into other PC, i will also change the path, am i right?!

i want to transfer my project folder without changing the path of all crystal reports.

is dr another way to lessen this problem?. i was thinking if i can call only call the folder name and the file name. for example, rpt.Load("foldername\cor.rpt").. how to do this? TIA.

#newbie

What I have tried:

rpt.Load(@"C:\Users\machuca\documents\visual studio 2010\Projects\enrollment\enrollment\reports\rptcor.rpt");
Posted
Updated 11-May-17 13:33pm
v2

1 solution

If you are making a Windows Forms application there is 2 methods;
a) Use a network share that will always be accessible - you could alternatively use a fixed location such as c:\Reports
b)Move your reports folder to the folder where the executable is and then use either;
C#
rpt.Load(System.Windows.Forms.Application.StartupPath + "\\Reports\\ReportName.rpt");

or
C#
rpt.Load(System.AppDomain.BaseDirectory + "\\Reports\\ReportName.rpt");


If you are making a ASP.Net application then you would create a Reports folder within your website (typically as a sub folder in the root of your web site) and then load the report using
C#
rpt.Load(Server.MapPath(@"~/Reports/ReportName.rpt"));


Kind Regards
 
Share this answer
 
Comments
akosisugar 12-May-17 1:50am    
my project is windows form.. i hv a release folder where my entire project files are inside including the the report folder.. so if i transfer the release folder into other PC, can i use this? "rpt.Load(System.Windows.Forms.Application.StartupPath + "\\Reports\\ReportName.rpt");" does this mean it will always locate the executable file in order to load the report?
an0ther1 15-May-17 1:16am    
Yep, that is correct.
The report will load from a sub directory in the folder that contains your Windows Form executable

Cheers
akosisugar 19-May-17 9:32am    
thank you!
Member 14660742 4-Feb-20 23:15pm    
I have made web application and i used your solution
rpt.Load(Server.MapPath(@"~/Reports/ReportName.rpt"));
But didn't work for me.
Please provide if any other solution is there.
I'm getting error in rpt.load(Path) line.
Thank you.

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