赛龙周 发表于 2024-5-13 06:09:11

插件开发中引用相对路径

我在开发插件中需要读取文件:string linqContent= File.ReadAllText("linq.min.js");

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

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


Ben.C 发表于 2024-5-13 06:09:12

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));

赛龙周 发表于 2024-5-13 10:03:42

Ben.C 发表于 2024-5-13 09:26
var dllDir = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Loc ...

感谢大神!
测试可以了!

Nathan.guo 发表于 2024-5-13 10:12:24

{:5_110:}
页: [1]
查看完整版本: 插件开发中引用相对路径