本文介绍了将文件导出到网络路径(CR XI)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 您好, 我尝试将excel表从asp.net应用程序(1.1)导出到网络路径。由于ASP.NET用户没有这样做的权限,我将导出线程个性化如下: public bool ExportReportEPS_PDF(string exportPath,System.Security.Principal.IIdentity userIdentity,long IPS_ID,out string error) { bool success = false; error =" ;" ;; CrystalDecisions.CrystalReports.Engine.Table crTable ; CrystalDecisions.CrystalReports.Engine.Tables crTables; TableLogOnInfo crTableLogOnInfo; EPS currentReport = new EPS(); currentReport.SetParameterValue(" IPS_ID",IPS_ID); currentReport.SetParameterValue(" COL_RED",220); currentReport.SetParameterValue(" COL_GREEN",220); currentReport.SetParameterValue(" COL_BLUE",220); crTables = currentReport.Database.Tables; for(int i = 0;我< crTables.Count; i ++) { crTable = crTables [i]; crTableLogOnInfo = crTable.LogOnInfo; crTableLogOnInfo.ConnectionInfo.Password =" eadb"; crTable.ApplyLogOnInfo(crTableLogOnInfo); } 尝试{ System.Security.Principal.WindowsImpersonationContext impersonationContext; impersonationContext =((System.Security.Principal.WindowsIdentity)userIdentity).Impersonate(); currentReport.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat,exportPath); success = true; impersonationContext.Undo(); } catch(System.IO.DirectoryNotFoundException){ error ="指定的路径不存在"; } catch( System.IO.IOException){ error =" Authentication失败。未知的用户名或密码。"; } 终于{ currentReport.Close(); currentReport.Dispose(); } 返回成功; } 导出路径设置为网络,如\\servername \\ \\ _directory\filename.pdf 不幸的是导出不起作用,因为我收到以下错误:拒绝访问\\servername \directory \ filename.pdf。 用户身份是当前的Windows登录,并且该用户有权写入光盘。 我希望有人可以帮我解决这个问题。 tia, Evelyn Hello,I try to export an excel-sheet from an asp.net application (1.1) to a network path. As the ASP.NET user doesn't have the permission to do this, I personalised the export-thread as follows:public bool ExportReportEPS_PDF(string exportPath, System.Security.Principal.IIdentity userIdentity, long IPS_ID, out string error) { bool success = false; error = ""; CrystalDecisions.CrystalReports.Engine.Table crTable; CrystalDecisions.CrystalReports.Engine.Tables crTables; TableLogOnInfo crTableLogOnInfo; EPS currentReport = new EPS(); currentReport.SetParameterValue("IPS_ID", IPS_ID); currentReport.SetParameterValue("COL_RED", 220); currentReport.SetParameterValue("COL_GREEN", 220); currentReport.SetParameterValue("COL_BLUE", 220); crTables = currentReport.Database.Tables; for (int i = 0; i < crTables.Count; i++) { crTable = crTables[ i]; crTableLogOnInfo = crTable.LogOnInfo; crTableLogOnInfo.ConnectionInfo.Password = "eadb"; crTable.ApplyLogOnInfo(crTableLogOnInfo); } try { System.Security.Principal.WindowsImpersonationContext impersonationContext; impersonationContext = ((System.Security.Principal.WindowsIdentity)userIdentity).Impersonate(); currentReport.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, exportPath); success = true; impersonationContext.Undo(); } catch (System.IO.DirectoryNotFoundException) { error = "The specified path doesn't exist"; } catch (System.IO.IOException) { error = "Authentication failed. Unknown username or password."; } finally { currentReport.Close(); currentReport.Dispose(); } return success; }The export path is set to a networkdivece like \\servername\directory\filename.pdfUnfortunately the export doesn't work, because I get the following error: Access to \\servername\directory\filename.pdf is denied.The user identity is the current windows-logon and that user has the permission to write an the disc.I hope somebody can help me with the problem.tia,Evelyn推荐答案 我建议从sysinternals.com下载一个名为filemon的实用工具。它监视所有应用程序完成的所有文件访问。这可以帮助确定拒绝访问的来源,以及正在被拒绝使用的用户。我建议运行filemon,获取日志,然后将文件重命名为.xls,并在excel中打开,使查看更加容易,而且您可以对数据进行排序。I would suggest downloading a utility called filemon from sysinternals.com. This monitors all file access done by all applications. This may help pinpoint where the access denied is coming from, as well as the user that is being used that is being denied. I suggest running filemon, getting the log, then renaming the file to .xls, and opening in excel, makes it a lot easier to view, plus you can sort the data. 这篇关于将文件导出到网络路径(CR XI)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-20 11:02