as you can see I am exporting crystal report to a PDF file but my problem is that the path of the crystal report RPT file and path of saving the oupt file (PDF File) since the path to folder at desktop is will be changed between PCs like
PC1 path code be
C:\Users\Xuser\Desktop
and on def rent pc is
C:\Users\XYPC\Desktop
so the path is not a static path .. anyway way out ?
Update:
now below code get the path to desktop but i am getting exception about access permissions which is access to path is denied
private void ExportToPDF()
{
ReportDocument cryrpt = new ReportDocument();
try
{
cryrpt.Load("INVOICE_REP.rpt");
ExportOptions CrExportOptions;
DiskFileDestinationOptions CrDiskFileDestinationOptions = new DiskFileDestinationOptions();
PdfRtfWordFormatOptions CrFormatTypeOptions = new PdfRtfWordFormatOptions();
CrDiskFileDestinationOptions.DiskFileName = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
MessageBox.Show(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory));
CrExportOptions = cryrpt.ExportOptions;
{
CrExportOptions.ExportDestinationType = ExportDestinationType.DiskFile;
CrExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat;
CrExportOptions.DestinationOptions = CrDiskFileDestinationOptions;
CrExportOptions.FormatOptions = CrFormatTypeOptions;
}
cryrpt.Export();
MessageBox.Show("Export Done");
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}