SAP Knowledge Base Article - Public

1933258 - CR for .NET SaveAs method always appends .rpt to the report

Symptom

When opening a report with an extension other than rpt when using the SaveAs method it appends .rpt to the report.

Environment

Crystal Reports Developer for Visual Studio 2010 +

Reproducing the Issue

rpt.load(@"c:\reports\myreport.don");

rptClientDoc = rpt.ReportClientDocument;

private void btnSaveReportAs_Click(object sender, System.EventArgs e)
{
    saveFileDialog.Filter = "Crystal Reports (*.rpt)|*.rpt";
    if (DialogResult.OK == saveFileDialog.ShowDialog())
    {

        object saveFolder = System.IO.Path.GetDirectoryName(saveFileDialog.FileName);
        string saveFileName = System.IO.Path.GetFileName(saveFileDialog.FileName);

        if (!IsRpt)
        {
            rptClientDoc.SaveAs(saveFileName, ref saveFolder,
                (int)CdReportClientDocumentSaveAsOptionsEnum.cdReportClientDocumentSaveAsOverwriteExisting);
        }
        else
        {
            try
            {
                rpt.SaveAs(saveFileName, true);
            }
            catch (Exception ex)
            {
                btnSQLStatement.Text = "ERROR: " + ex.Message;
            }
        }
    }
}

Saves the report as myreport.don.rpt

Resolution

Because Current versions of Windows allow multiple periods in the file name CR for .NET simply appends RPT to the file name.

Previously this would have replaced the extension.

Work around is to rename the file outside of CR .NET API's

Keywords

KBA , BI-DEV-NET , BI Software Development Kits (SDKs) - .NET or Other , Problem

Product

Crystal Reports 2008 V0 ; SAP Crystal Reports, developer version for Microsoft Visual Studio