我在将pdf文件保存到网络的路径目录时遇到问题,但是保存到本地文件夹时工作正常。
我已经尝试过显示几个代码。我还更改了网络文件夹的安全权限,以添加“网络服务”(在线),并具有修改,读取和执行,列出文件夹内容,读取,写入的权限(我是否需要特殊权限或完全控制权?)。我在做什么错?
***本地文件夹:成功
Telerik.Reporting.Processing.ReportProcessor reportProcessor = new ReportProcessor();
RenderingResult result = reportProcessor.RenderReport("PDF", instanceReportSource, null);
string documentName = ProductionInstructionPrintPage.plantCode + ProductionInstructionPrintPage.machine + ProductionInstructionPrintPage.ordNum;
string filePath = @"C:\Users\Lily\Desktop\SavingPdfTesting";
string fileName = documentName + "." + result.Extension;
string full_path = filePath + fileName;
//writes the pdf to disk
using (FileStream fs = new FileStream(full_path, FileMode.Create))
{
fs.Write(result.DocumentBytes, 0, result.DocumentBytes.Length);
}
***网络尝试1:失败-访问被拒绝
Telerik.Reporting.Processing.ReportProcessor reportProcessor = new ReportProcessor();
RenderingResult result = reportProcessor.RenderReport("PDF", instanceReportSource, null);
string documentName = ProductionInstructionPrintPage.plantCode + ProductionInstructionPrintPage.machine + ProductionInstructionPrintPage.ordNum;
string filePath = @"\\\\testing.company.com\reports\";
string fileName = documentName + "." + result.Extension;
string full_path = filePath + fileName;
//writes the pdf to disk
using (FileStream fs = new FileStream(full_path, FileMode.Create))
{
fs.Write(result.DocumentBytes, 0, result.DocumentBytes.Length);
}
***网络尝试#2:失败-访问被拒绝
Telerik.Reporting.Processing.ReportProcessor reportProcessor = new ReportProcessor();
RenderingResult result = reportProcessor.RenderReport("PDF", instanceReportSource, null);
string documentName = ProductionInstructionPrintPage.plantCode + ProductionInstructionPrintPage.machine + ProductionInstructionPrintPage.ordNum;
string filePath = @"\\testing.company.com\reports\";
string fileName = documentName + "." + result.Extension;
string full_path = filePath + fileName;
//writes the pdf to disk
using (FileStream fs = new FileStream(full_path, FileMode.Create))
{
fs.Write(result.DocumentBytes, 0, result.DocumentBytes.Length);
}
***网络尝试#3:失败-找不到目录
Telerik.Reporting.Processing.ReportProcessor reportProcessor = new ReportProcessor();
RenderingResult result = reportProcessor.RenderReport("PDF", instanceReportSource, null);
string documentName = ProductionInstructionPrintPage.plantCode + ProductionInstructionPrintPage.machine + ProductionInstructionPrintPage.ordNum;
string filePath = @"I:\testing.company.com\reports\";
string fileName = documentName + "." + result.Extension;
string full_path = filePath + fileName;
//writes the pdf to disk
using (FileStream fs = new FileStream(full_path, FileMode.Create))
{
fs.Write(result.DocumentBytes, 0, result.DocumentBytes.Length);
}
检查共享的权限。如您所述,您已向“网络服务”添加了权限,但是运行您的应用程序的用户是什么?