如何获取DLL库中的文件。 [英] How do I get a file inside of my DLL library.
问题描述
您好我正在创建自己的库,所以我可以在其他项目中使用它。在我的DLL中,我有需要重新加载的xml文件。我做了这个代码来阅读它但它不起作用。
var buildDir = new System.Uri(System.Reflection.Assembly.GetExecutingAssembly()。Location).LocalPath;
var filePath = buildDir + @ \\ \\RoundTypes\StartRound.xml跨度>;
startRound = XDocument.Load(filePath);
我收到此错误:
System.IO.DirectoryNotFoundException:'无法找到路径的一部分'F:\ VS projects \SurvivalGamesLib \SurvivalGamesLibConsole\bin\Debug \\\
etcoreapp2.1 \SurvivalGamesLib.dll \\ \\ _RoundTypes \StartRound.xml'。'
我正在使用控制台测试库,这就是为什么它在existsgamesconsole里面的库本身被命名为survivalgameslib。
这就是文件在dll中的位置。
< a href =https://imgur.com/a/3bZxPJi>点击此处查看图片 [ ^ ]
有人可以帮忙吗?
我尝试了什么:
在Google上搜索但我没有找到任何有助于我的情况
构建文件操作 - Visual Studio | Microsoft Docs [ ^ ]
Hello I'm making my own library so I can use it in other projects. In my dll I have xml files that need to be readed. I made this code to read it But it does not work.
var buildDir = new System.Uri(System.Reflection.Assembly.GetExecutingAssembly().Location).LocalPath;
var filePath = buildDir + @"\RoundTypes\StartRound.xml";
startRound = XDocument.Load(filePath);
I get this error:
System.IO.DirectoryNotFoundException: 'Could not find a part of the path 'F:\VS projects\SurvivalGamesLib\SurvivalGamesLibConsole\bin\Debug\netcoreapp2.1\SurvivalGamesLib.dll\RoundTypes\StartRound.xml'.'
I'm testing the library with a console thats why it is inside survivalgamesconsole the library itself is named survivalgameslib.
this is how the files are located in the dll itself.
click here for picture[^]
Can someone help?
What I have tried:
Searching on google but I did not find anything that helps in my situation
Check the "Build Action" on your file against what your are trying to accomplish.
Build actions for files - Visual Studio | Microsoft Docs[^]
这篇关于如何获取DLL库中的文件。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!