就放在同一个目录下在设计时,把报表文件Copy到\bin\debug\下使用如果你使用Release编译,EXE又会跑到\bin\Release下的,所以放同一个目录比较好

解决方案 »

  1.   

    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;
      

  2.   

    方法一:把报表文件放在同一个目录,或者把报表文件放在相对于Exe文件固定的目录;
    方法二:写成参数文件,通过参数文件来获得。
      

  3.   

    我现在的项目路径是 :projectname\ exe在projectname\bin\debug\ 报表文件在projectname\  程序发布时我想应是 projectname\bin\.exe   而报表就是在projectname\
    那么我现在在设计时如何在程序中设置报表的路径,使它在发布是不会出错
      

  4.   

    用条件编译:
    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 
      

  5.   

    用如下语名可获得应用程序当前的路径
    Application.StartupPath
    --------------推广.NET应用,助力信息化中国(IsClever)
      

  6.   

    若exe在\bin\debug\下
    而文件在\ 下,则文件的相对路径为..\\..\\exe程序