从 resx 文件访问文本文件
我以前有过使用 File.ReadAllLines() 读取文本文件并将每一行存储到字符串数组中的代码。
不过,我决定将文本文件存储在 ResX 文件中会更好。
我已将文本文件添加到 ResX 文件中。我知道我可以使用“resourceManager.GetString”来读取文本文件,但这不允许我用文本文件中的每一行填充字符串数组。这怎么能做到呢?
(我尝试的一件事是将服务文件的访问修饰符更改为“public”,然后尝试访问文本文件的内容,但由于某种原因自动生成的文件无法构建...)
I previously had code that used File.ReadAllLines()
to read a text file and store each line into a string array.
However I have decided that the text file would be better stored in a ResX file.
I have added the text file to the ResX file. I know I could use 'resourceManager.GetString' to read the text file but this does not allow me to populate a string array with each line in the text file. How can this be done?
(One thing I tried was was changing the access modifier for the services file to 'public', and then trying to access the contents of the text file but for some reason the auto-generated file failed to build...)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
http://msdn.microsoft.com/en-us /library/system.io.stringreader.readline.aspx
http://msdn.microsoft.com/en-us/library/system.io.stringreader.readline.aspx