cancel
Showing results for 
Search instead for 
Did you mean: 

Access to report file denied. Another program may be using it

Former Member
0 Kudos

The following error occurred:
Error in File C:\Windows\TEMP\AC01 {6BDA6012-685C-467C-BB99-E2BE77C5D3F1}.rpt: Access to report file denied. Another program may be using it.

run in IIS in win 7 got this error,

run in visual studio can export pdf successfully

After searched, it said remove impersonate = true , however another function for exporting Excel need this

  

    protected void ExportPDFButton_Click(object sender, EventArgs e)
    {
        ReportDocument objRpt = new ReportDocument();
        string reportPath = @"C:\sap\Addon\CPS_Crystal800\CrystalReports\AC01.rpt";
        objRpt.Load(reportPath);

        int projindex = ddlProject.SelectedIndex;
        string projValue = ddlProject.Items[projindex].Value.ToString();

        //objRpt.SetDatabaseLogon("sa", "compass2008", "10.1.1.42", "PAY800");

        TableLogOnInfo crtableLogoninfo = new TableLogOnInfo();
        ConnectionInfo crConnectionInfo = new ConnectionInfo();
        CrystalDecisions.CrystalReports.Engine.Tables CrTables;
        //Table CrTable;
       
        crConnectionInfo.ServerName = "X.X.X.X";
        crConnectionInfo.UserID = "sa";
        crConnectionInfo.Password = "XXX";
        crConnectionInfo.DatabaseName = "XXX";

        objRpt.SetParameterValue(0, projValue);
        objRpt.SetParameterValue(1, projValue);
       
        CrTables = objRpt.Database.Tables;

        foreach (CrystalDecisions.CrystalReports.Engine.Table CrTable in CrTables)
        {
            crtableLogoninfo = CrTable.LogOnInfo;
            crtableLogoninfo.ConnectionInfo = crConnectionInfo;
            CrTable.ApplyLogOnInfo(crtableLogoninfo);
        }

        ExportOptions exportOpts = new ExportOptions();
        DiskFileDestinationOptions diskOpts = new DiskFileDestinationOptions();
        exportOpts = objRpt.ExportOptions;
        exportOpts.ExportDestinationType = ExportDestinationType.DiskFile;
        exportOpts.ExportFormatType = ExportFormatType.PortableDocFormat;
        diskOpts.DiskFileName = "C:\\ACIReport.pdf";
        exportOpts.DestinationOptions = diskOpts;

        //objRpt.ExportToHttpResponse(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat
        objRpt.ExportToHttpResponse(exportOpts, this.Page.Response, true, "ACI01" + DateTime.Now.ToString("yyyyMMdd"));
    }

Accepted Solutions (1)

Accepted Solutions (1)

AndrewBaines
Participant
0 Kudos

Does the account used by IIS have access to the root of C: ? I kind of hope not!

Try changing it to the TEMP folder, see if it works.

Former Member
0 Kudos

solved by grant IIS_USR to TEMP, discover diskOpts.DiskFileName has no effect to change path, as it still using default path c:\windows\temp

Answers (0)