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
I read an embedded resource text file use:
///
/// Converts to generic list a byte array
///
/// byte array (embedded resource)
/// generic list of strings
private List GetLines(byte[] content)
{
string s = Encoding.Default.GetString(content, 0, content.Length - 1);
return new List(s.Split(new[] { Environment.NewLine }, StringSplitOptions.None));
}
Sample:
var template = GetLines(Properties.Resources.LasTemplate /* resource name */);
template.ForEach(ln =>
{
Debug.WriteLine(ln);
});