How to read embedded resource text file

前端 未结 22 2328
悲&欢浪女
悲&欢浪女 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

    I know it is an old thread, but this is what worked for me :

    1. add the text file to the project resources
    2. set the access modifier to public, as showed above by Andrew Hill
    3. read the text like this :

      textBox1 = new TextBox();
      textBox1.Text = Properties.Resources.SomeText;
      

    The text that I added to the resources: 'SomeText.txt'

提交回复
热议问题