Quantcast
Channel: SCN : Discussion List - SAP Crystal Reports, version for Visual Studio
Viewing all articles
Browse latest Browse all 3636

C# console app export crystal report error

$
0
0

The following code running fine on my PC, but when I publish the app to the server and install it. It gives me error. This is a console app, targeting .net framework 4,

 

 

string pdf =Environment.GetFolderPath(
  
System.Environment.SpecialFolder.DesktopDirectory)+"\\zzz.pdf";

  
string rpt =Environment.GetFolderPath(
  
System.Environment.SpecialFolder.DesktopDirectory)+"\\zzz.rpt";
  
ReportDocument cryRpt;
  cryRpt
=newReportDocument();
  cryRpt
.Load(rpt);
  cryRpt
.SetDatabaseLogon("******","*******");

  
//cryRpt.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, pdf");

  
MemoryStream memoryStream =newMemoryStream();
  
Stream exportStream = cryRpt.ExportToStream(ExportFormatType.PortableDocFormat);
  exportStream
.CopyTo(memoryStream);

  
byte[] content = memoryStream.ToArray();

  
// Write out PDF from memory stream.
  
Console.WriteLine(pdf);
  using
(FileStream fs =File.Create(pdf))
  
{
  fs
.Write(content,0,(int)content.Length);
  
}

 

 

  This is the error When I using "ExportToStream" it gives me error as the following. When I export it to disk it gives me the similar error instead of using ExportToSteam. What I don;t get is When I am exporting it as stream, I am pointing to any location , why does it throw me "The system can not find the path specified"

Capture.JPG


Viewing all articles
Browse latest Browse all 3636

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>