1

I have a JSON file full of language codes that I want to import in as a string, the language file is located in a project of the solution full of "shared" resources. I'm a bit confused on the piece to be able to load in the file. I think I understand what to do after that but if there is a better way to do it please let me know. Thanks!

  1. Project "ProjectName.Resources" in solution All.sln a. in folder Shared.Resources/Language Files/language_file.json

  2. Trying to access language_file.json from project "ProjectName.Languages" also in solution All.sln

  3. After loading in language_file.json I'll use newtonsoft to deserialize it

Taylor
  • 81
  • 10
  • So what it is the actual problem? The bits of how to load a file in code or to find the file from code? If it's about reading a file into a string you can try google: "C# read file as string" – Michael May 27 '20 at 19:18
  • Also remember that if the files are part of a project their properties should be set to `Content` and `Copy if newer`. – Michael May 27 '20 at 19:19
  • @Michael my question is how do I create the reference to the json file that is in the other project, I don't know how to do that and I can't find a clear answer from Google. – Taylor May 27 '20 at 20:23
  • First make sure that the json files are copied to the output folder on build. You do that by right clicking the file and choose Properties. Set `Build action` to `Content` and `Copy to output directory` to `Copy if newer`. From here you can google how to read a file into a string. – Michael May 27 '20 at 20:27
  • Do [How to get resources embedded in another project](https://stackoverflow.com/q/17569931) or [Accessing a resource file from another project C# .Net](https://stackoverflow.com/q/38332325) or [Visual Studio - Resx File default 'internal' to 'public'](https://stackoverflow.com/q/4274311) answer your question? [Read from a JSON file inside a project](https://stackoverflow.com/q/25081766) might also answer your question. – dbc May 27 '20 at 21:18

0 Answers0