[C#在网络路径目录上创建文件时拒绝访问

问题描述 投票:0回答:1

我在将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);
            }
c# report filestream filepath telerik-reporting
1个回答
0
投票

检查共享的权限。如您所述,您已向“网络服务”添加了权限,但是运行您的应用程序的用户是什么?

© www.soinside.com 2019 - 2024. All rights reserved.