如何前往RDLC报告中的相对路径在我的winform应用程序 [英] Getting the relative path to the rdlc report in my winform app

查看:1367
本文介绍了如何前往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.

这篇关于如何前往RDLC报告中的相对路径在我的winform应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆