Click here to Skip to main content
15,888,158 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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.
C#
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
Posted
Updated 23-Apr-19 8:19am
v2
Comments
ZurdoDev 23-Apr-19 13:52pm    
What exactly is the problem? The errors says it can't find the path.
phil.o 23-Apr-19 14:00pm    
Are you unable to check the path which is reported to you, and to acknowledge it is not a valid path?
dolfijn3000 23-Apr-19 14:01pm    
the problem is taht the path is there but it says not i cheked it manualy. the only bit im not sure is at SurvivalGamesLib.dll\RoundTypes\StartRound.xml'. is this the correct way to acces data inside dll's ?

1 solution

Check the "Build Action" on your file against what your are trying to accomplish.

Build actions for files - Visual Studio | Microsoft Docs[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900