水晶报表通过安装部署发布以后,到客户机上安装程序,提示水晶报表加载失败,我查了一下是路径设置有问题,我想问一下我要怎么获取我的程序安装的路径呢
1条回答 默认 最新
- 张云勇 2016-09-13 05:58关注
///
/// 获取文件路径
///
///
public static string GetCurrentDirectory()
{
string fullName = Assembly.GetExecutingAssembly().GetName().CodeBase;
string fullPath = Path.GetDirectoryName(fullName);
if(fullPath.StartsWith("file:"))
{
fullPath = fullPath.Substring(6);
}
return fullPath;
}
///
/// 获取文件路径
///
/// 文件名
///
public static string GetCurrentDirectory(string fileName)
{
string fullName = Assembly.GetExecutingAssembly().GetName().CodeBase;
string fullPath = Path.GetDirectoryName(fullName);
if(fullPath.StartsWith("file:"))
{
fullPath = fullPath.Substring(6);
}
return fullPath + "\" + fileName;
}解决 无用评论 打赏 举报