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.
我在测试某些软件时使用了一些测试数据(json文件)。它是静态数据,我需要测试在本地运行和在我无需控制的构建机器上运行。为了统一访问测试数据(json文件),我将它们放入一个RESX文件中,除了我必须将文件的扩展名从.json更改为.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.
如果我将其保留为.json,则会将其作为“二进制”而不是“文本文件”添加到resx文件中。这本身并不是道路的终点...我只是读出这些位并将其转换回字符串但是当我尝试反序列化字符串时(在从byte []转换之后)我得到了一个意外的异常char位于0位置0。
The only real downside to the "txt" extension is that I loose the color coding in the IDE for a JSON file.
“txt”扩展的唯一真正缺点是我在IDE中为JSON文件丢失了颜色编码。
Is there a way to force the RESX to treat the .json extension as a "Text File"?
有没有办法强制RESX将.json扩展名视为“文本文件”?
1 个解决方案
#1
7
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.
也许为时已晚,但有一种非常简单的方法可以达到你想要的效果。只需在资源窗口中选择所需的文件,点击F4或转到属性并在那里选择适当的FileType。它有两个选项:二进制和文本。
#1
7
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.
也许为时已晚,但有一种非常简单的方法可以达到你想要的效果。只需在资源窗口中选择所需的文件,点击F4或转到属性并在那里选择适当的FileType。它有两个选项:二进制和文本。