1

我尝试通过RadPdf控件打开我的 PDF,但出现渲染错误。我检查事件查看器并获取以下数据:为了解决我必须创建的问题,C:\WINDOWS\TEMP\RadPdfTemp\并且管理员每隔一段时间清空 temp 并删除此文件夹,我尝试在我的网站中创建具有所需权限的此文件夹,但是仍然得到同样的错误!


 this.rad_pdf.CreateDocument("Document Name", pdfData);

pdfData通过:

 private byte[] AddReportToResponse(LocalReport followsReport)
    {
        string mimeType;
        string encoding;
        string extension;
        string[] streams = new string[100];
        Warning[] warnings = new Warning[100];
        byte[] pdfStream = followsReport.Render("PDF", "", out mimeType, out encoding, out extension, out streams, out warnings);


        return pdfStream;
    }

Event Type: Error
Event Source:   RAD PDF
Event Category: None
Event ID:   0
Date:       4/21/2013
Time:       2:33:50 PM
User:       N/A
Computer:   -----
Description:
Event Category
-----------------
PdfService

Event Description
-----------------
RAD PDF Service Message Worker Thread Unknown Exception
Exception Type:
System.IO.DirectoryNotFoundException
Exception Message:
Could not find a part of the path 'C:\WINDOWS\TEMP\RadPdfTemp\p476.tmp'.
Exception Stack Trace:
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
   at System.IO.File.WriteAllBytes(String path, Byte[] bytes)
   at #Ew.#Rw.#ix()
   at #Ew.#Rw.#9w()

Event User
-----------------
NT AUTHORITY\SYSTEM

Event Version
-----------------
2.12.0.0

For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.
4

1 回答 1

3

您应该检查临时文件夹是否存在,否则在打开 PDF 文件之前创建它。这将确保文件夹在那里并且不会引发异常。

string tempDirectory = Path.Combine(Path.GetTempPath(), "RadPdfTemp");

if (!Directory.Exists(tempDirectory))
    Directory.CreateDirectory(tempDirectory);

this.rad_pdf.CreateDocument("Document Name", pdfData);
于 2013-04-30T08:58:15.937 回答