How to read embedded resource text file

前端 未结 22 2334
悲&欢浪女
悲&欢浪女 2020-11-21 06:03

How do I read an embedded resource (text file) using StreamReader and return it as a string? My current script uses a Windows form and textbox that allows the

22条回答
  •  渐次进展
    2020-11-21 06:57

    For all the people that just quickly want the text of a hardcoded file in winforms;

    1. Right-click your application in the solution explorer > Resources > Add your file.
    2. Click on it, and in the properties tab set the "FileType" to "Text".
    3. In your program just do Resources..toString(); to read the file.

    I would not recommend this as best practice or anything, but it works quickly and does what it needs to do.

提交回复
热议问题