找回密码
 立即注册

QQ登录

只需一步,快速开始

赛龙周
金牌服务用户   /  发表于:2024-5-13 06:09  /   查看:224  /  回复:3
10金币
我在开发插件中需要读取文件:string linqContent= File.ReadAllText("linq.min.js");

已经将文件放在Resources/linq.min.js文件夹中

现在碰到的问题,如何来配置相对路径,从插件目录中读取,而不是程序主文件目录。


附件: 您需要 登录 才可以下载或查看,没有帐号?立即注册

最佳答案

查看完整内容

var dllDir = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location.ToString()); var jsPath = System.IO.Path.Combine(dllDir, "Resources", "linq.min.js"); var json = File.ReadAllText(System.IO.Path.GetFullPath(jsPath));

3 个回复

倒序浏览
最佳答案
最佳答案
Ben.C
注册会员   /  发表于:2024-5-13 06:09:12
来自 2#
  var dllDir = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location.ToString());
  var jsPath = System.IO.Path.Combine(dllDir, "Resources", "linq.min.js");
  var json = File.ReadAllText(System.IO.Path.GetFullPath(jsPath));

评分

参与人数 1金币 +5 收起 理由
Nathan.guo + 5 很给力!

查看全部评分

回复 使用道具 举报
赛龙周
金牌服务用户   /  发表于:2024-5-13 10:03:42
3#
Ben.C 发表于 2024-5-13 09:26
var dllDir = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Loc ...

感谢大神!
测试可以了!
回复 使用道具 举报
Nathan.guo活字格认证 Wyn认证
超级版主   /  发表于:2024-5-13 10:12:24
4#
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部