23

I have some test data (json files) that I am using while testing some software. It is static data and I need the tests to run locally and on build machines that I don't have to much control of. In order to get uniform access to the test data (json files) I have put them into a RESX file and that is working nicely except that I had to change the extension of the file from .json to .txt.

If I left it as .json it was added to the resx file as a "Binary" instead of "Text File". This by itself wasn't the end of the road... I simply read out the bits and converted it back to a string but when I tried to deserialize the string (after the conversion from byte[]) I got an exception for unexpected char at position 0 line 0.

The only real downside to the "txt" extension is that I loose the color coding in the IDE for a JSON file.

Is there a way to force the RESX to treat the .json extension as a "Text File"?

Ryan Pedersen
  • 3,177
  • 27
  • 39

2 Answers2

35

Maybe it's too late, but there is a very simple method to achieve what you want. Just select the desired file in the resources window, hit F4 or go to the Properties and select proper FileType there. It has two options: binary and text.

enter image description here

Axm
  • 617
  • 1
  • 7
  • 11
1

A colleague of mine just encountered a similar issue with a .cshtml file. The actual content of the file didn't seem to matter when we renamed the file to have an extension that was known to work caused it to add as text.

Also, Axm's suggestion worked to fix it, but we initially missed it because you can't right-click on the resource and select properties.

drs9222
  • 4,448
  • 3
  • 33
  • 41