如何前往RDLC报告中的相对路径在我的winform应用程序
我自动创建我们的一些在月末处理报告的PDF文件。我遇到了一个问题,即 ReportViewer.LocalReport
找不到我的报告。在项目中,报告文件是在(项目根文件夹)/Reports/report.rdlc。
I am automatically creating a PDF from some of our reports in a month-end process. I am running into a problem where ReportViewer.LocalReport
can't find my report. Within the project, the report files are in "(project root folder)/Reports/report.rdlc".
如何设置的ReportViewer。 LocalReport.ReportPath
这样我就可以参考我的报告文件?
我宁愿没有设置的完整路径,因为我不知道在客户机安装时,将安装做的。
How do I set ReportViewer.LocalReport.ReportPath
so I can reference my report file?
I would rather not set the full path because I don't know where it would be installed when installed on the client machines.
使用的Application.StartupPath财产,它总是指向目录,你的EXE位于:
Use the Application.StartupPath property, it always points to directory where your EXE is located:
using System.IO;
...
string exeFolder = Application.StartupPath;
string reportPath = Path.Combine(exeFolder, @"Reports\report.rdlc");
您会希望确保该报告被复制到文件夹bin\Debug\Reports也因此会在IDE中工作。使用XCOPY / S / D的生成后事件得到复制的文件(S)。
You'll want to make sure the report gets copied to your bin\Debug\Reports folder as well so it will work in the IDE. Use xcopy /s /d in a post-build event to get the file(s) copied.