Click here to Skip to main content
15,886,067 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I want to have at least a better way to load my crystal report in my c# windows form by not using a long file path.

What I have tried:

So I tried implementing the long file path which is:
C#
inv.Load(@"C:\Users\jonat\onedrive\documents\visual studio 2015\Projects\FunctionApp\FunctionApp\InventoryReport.rpt");


I also tried this:
C#
inv.Load(Path.GetDirectoryName("InventoryReport.rpt"));


Also this one:
C#
inv.Load(Application.StartupPath + "InventoryReport.rpt");


None of the two worked, I also tried the file path with ("~\\") but also didn't worked
Posted
Updated 25-Apr-19 17:51pm
Comments
Richard MacCutchan 27-Oct-18 12:01pm    
Define “didn’t work”.
Richard Deeming 30-Oct-18 12:58pm    
Path.GetDirectoryName("InventoryReport.rpt") will return an empty string, because the path you've passed in doesn't contain a directory.

Perhaps you meant Path.GetFullPath("InventoryReport.rpt") instead?

1 solution

Winforms Desktop :
C#
report2.Load(@"" + Application.StartupPath + @"\Reports\Driver_Kart.rpt");



Web Forms:
C#
report2.Load(Server.MapPath(@"~\Reports\ProjectReport.rpt"));
 
Share this answer
 
v3

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