c#中的文件路径设置 就放在同一个目录下在设计时,把报表文件Copy到\bin\debug\下使用如果你使用Release编译,EXE又会跑到\bin\Release下的,所以放同一个目录比较好 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 string appPath=Application.StartupPath;System.IO.DirectoryInfo strDir=System.IO.Directory.GetParent(appPath);string tempPath=strDir.fullName;System.IO.DirectoryInfo reportDir=System.IO.Directory.GetParent(tempPath);//下面是你要的string reportPath=reportDir.fullName; 方法一:把报表文件放在同一个目录,或者把报表文件放在相对于Exe文件固定的目录;方法二:写成参数文件,通过参数文件来获得。 我现在的项目路径是 :projectname\ exe在projectname\bin\debug\ 报表文件在projectname\ 程序发布时我想应是 projectname\bin\.exe 而报表就是在projectname\那么我现在在设计时如何在程序中设置报表的路径,使它在发布是不会出错 用条件编译:string appPath=Application.StartupPath#if DEBUGstring reportPath=System.IO.Directory.GetParent(System.IO.Directory.GetParent(appPath).fullName).FullName+@"\report"; //去掉bin\debug#elsestring reportPath = appPath +@"\report";#endif 用如下语名可获得应用程序当前的路径Application.StartupPath--------------推广.NET应用,助力信息化中国(IsClever) 若exe在\bin\debug\下而文件在\ 下,则文件的相对路径为..\\..\\exe程序 求一个正则表达式,替换重复的数字 全国计算机等级考试超级模拟软件能够评测vb程序,它的原理是什么呢? WinFrom TreeView 数据库动态加载方式,在线等 我是个菜,我承认! C#窗体更新的问题 C# winform开发 如何去掉一个控件响应事件 求救:在showModalDialog弹出页面中修改数据成功后,数据库已更新,但再次弹出发现显示数据还是以前的? 如何实现.exe文件唯一运行? C#中,请问如何将当前的时间入到Access数据库中? 怎样在已存在的XML文件中删除指定的接点 DropDownList捆绑数据问题急!急!急!急!急!急!
System.IO.DirectoryInfo strDir=System.IO.Directory.GetParent(appPath);
string tempPath=strDir.fullName;
System.IO.DirectoryInfo reportDir=System.IO.Directory.GetParent(tempPath);//下面是你要的
string reportPath=reportDir.fullName;
方法二:写成参数文件,通过参数文件来获得。
那么我现在在设计时如何在程序中设置报表的路径,使它在发布是不会出错
string appPath=Application.StartupPath
#if DEBUG
string reportPath=System.IO.Directory.GetParent(System.IO.Directory.GetParent(appPath).fullName).FullName+@"\report"; //去掉bin\debug
#else
string reportPath = appPath +@"\report";
#endif
Application.StartupPath
--------------推广.NET应用,助力信息化中国(IsClever)
而文件在\ 下,则文件的相对路径为..\\..\\exe程序