This is a migrated thread and some comments may be shown as answers.

error while xreating pdf report at runtime

1 Answer 119 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Mauro
Top achievements
Rank 1
Mauro asked on 22 Mar 2009, 12:09 PM
Hi,

I have developed a web site where I use this function:

Dim report1 As New Report1()
Dim mimType As String = String.Empty
Dim extension As String = String.Empty
Dim encoding As Encoding = Nothing
Dim buffer_it As Byte() = Telerik.Reporting.Processing.ReportProcessor.Render("PDF", report1, Nothing, mimType, extension, encoding)
Dim fs_it As New FileStream(strAttachment_pdf_path & id_ordineRif & "_1_ITALIANO.pdf", FileMode.Create)
fs_it.Write(buffer_it, 0, buffer_it.Length)
fs_it.Flush()
fs_it.Close()

to create a PDF file from a telerik report at runtime.

On the development machine it works well.
When I deploy the web site on the remote server, I have this permission error:

"Access to the path 'c:\windows\system32\inetsrv\1159_MauroCattaneo_1_ITALIANO.pdf' is denied"

I understand that telerik code use this folder to create a temporary file, am I wrong?

I ask my provider to give my website permission to this folder, but I don't know if they agree...

Is there another way for me?

Thanks in advance...

Best Regards
Mauro Cattaneo - Italy

1 Answer, 1 is accepted

Sort by
0
Milen | Product Manager @DX
Telerik team
answered on 23 Mar 2009, 09:59 AM
Hello Mauro,

Telerik Reporting is not making any temporary files while exporting your report.

In your code you are using framework's FileStream class to save a file to the file system on the web server. If that is what you want to accomplish, most probably the only place on the server where you have permissions to save/delete files is inside your own site. From the error shown it seems that you are trying to save the file in the working directory of the web server, where you do not have permissions for sure.

Check out the following code snippet showing how to save a file inside your application folder:

        string physicalPath = HttpContext.Current.Request.PhysicalApplicationPath;
        System.Diagnostics.Debug.WriteLine("Apllication phisical path: " + physicalPath);

        string myPath = physicalPath + "TestFile.txt";
        using (FileStream stream = new FileStream(myPath, FileMode.Create))
        {
            byte[] bytes = Encoding.ASCII.GetBytes("Test content.");
            stream.Write(bytes, 0, bytes.Length);
        }


Also if your final goal is to serve the exported pdf file to the client you do not need to save the byte array on the server at all. If that is the case, here is a KB article on the subject with the needed snipped.

Write us if you need further assistance.

Greetings,
Milen
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
Tags
General Discussions
Asked by
Mauro
Top achievements
Rank 1
Answers by
Milen | Product Manager @DX
Telerik team
Share this question
or