Csibi Norbert
Csibi Norbert

Reputation: 930

How to load json file in c# from relative path?

I have a problem with localizing the JSON file inside my folder. I have a test class, and in the same directory, I have a JSON file. So what I want to achieve is to retrieve the JSON file with a relative path.

enter image description here

And the thing that I have tried is this

 var jsonString = File.ReadAllText("\\TemplateUrlOk.json");

UPDATE

This is the structure of the test project.

enter image description here

Upvotes: 4

Views: 12925

Answers (1)

Csibi Norbert
Csibi Norbert

Reputation: 930

I will be answering my question, hence I found the problem.

@ADyson mentioned that the JSON file needs to be copied in the directory when the project builds, which I did. However, it was in another folder called EmailController and the filename.

Upvotes: 1

Related Questions