Winform根目录路径。如何再次! [英] Winform root directory path.How to again!

查看:183
本文介绍了Winform根目录路径。如何再次!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,你们首先对于提出这样一个简单而冗长的问题表示歉意,但似乎我的情况有点不同,谷歌搜索未能提供答案。
我有一个解决方案,有2个项目说proj1和proj2其中proj1是一个winform应用程序,proj2是一个类库application.proj1坐在这里


C:\Documents and Settings\myname\My Documents\Visual Studio 2005\Projects\proj1\proj1


ane该类库在这里


C:\Documents and Settings\myname\My Documents\Visual Studio 2005\Projects\proj1\proj2


现在我有一个子文件夹报告中的报告,我有我的crystalreport和其他东西
i需要具有proj1的这个根路径


C:\Documents and Settings\myname\My Documents\ Visual Studio 2005\Projects\proj1\proj1


所以我追加 @Report\ myreport.rpt。我相信这应该是部署机器上的相对路径。如果我错了,请更正我的主要想法是在


C:\Documents and Settings\myname\My Documents\Visual Studio 2005\Projects\proj1\proj\Report。


从我所有在线搜索
喜欢 Environment.CurrentDirectory Application.StartupPath Application.ExecutablePath System.Reflection.Assembly.GetExecutingAssembly()。位置只是给我bin / proj1.exe或调试文件夹。
我只是无法弄清楚如何做到这一点



谢谢你阅读this.oh是的!为你的答案。
PS:使用C#2.0

解决方案

你只需要设置属性Copy to Output Directory报告文件为全部复制或复制(如果较新)。这将在构建期间将报告复制到实际的输出目录下,您可以使用 Path.Combine(Application.StartupPath,Reports,report.rpt)访问它


Hello guys first of all apologize for asking such a simple and yet redundant question but it seems my case is kinda bit different where googling failed to provide answers. I have a solution with 2 projects say proj1 and proj2 where proj1 is a winform application and proj2 is a classlibrary application.proj1 is sitting here

C:\Documents and Settings\myname\My Documents\Visual Studio 2005\Projects\proj1\proj1

ane the classlibrary is here

C:\Documents and Settings\myname\My Documents\Visual Studio 2005\Projects\proj1\proj2

Now i have a report in a subfolder Report where i have my crystalreport and other stuffs i need to have this root path of proj1

C:\Documents and Settings\myname\My Documents\Visual Studio 2005\Projects\proj1\proj1

so that i append @"Report\myreport.rpt" to it. I believe with that it's supposed to be relative path on the deployed machine.correct me if I'm wrong.the main idea is to have relative path to the Report folder at

C:\Documents and Settings\myname\My Documents\Visual Studio 2005\Projects\proj1\proj\Report.

from all i searched online like Environment.CurrentDirectoryor Application.StartupPath or Application.ExecutablePath or System.Reflection.Assembly.GetExecutingAssembly().Location are just given me either the bin/proj1.exe or the debug folder. i just can't figure out how to do that

thank you for reading this.oh yeah! and for your kind answer. PS: using C#2.0

解决方案

You just have to set the property "Copy to Output Directory" of the report file to "Copy allways" or "Copy if newer". This will copy the report below the actual output directory during a build and you can access it with Path.Combine(Application.StartupPath, "Reports", "report.rpt").

这篇关于Winform根目录路径。如何再次!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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