I know this is an old question but as I was lurking around these parts on this exact topic... here's my take:
From what I can see, the resource text file is being treated as a text file where it is hoped File.ReadAllLines(Conundrum.Properties.Resources.Words)
would read the lines within the .txt file as strings.
However, by using ReadAllLines()
this way, it immediately reads the first line as the filepath name, hence the error message.
I suggest adding the file as a resource as per this answer from @Contango.
Then, as per this answer from @dtb, with a little bit of modification, you will be able to read the text file contents:
using System.Reflection; //Needs this namespace for StreamReader
var assembly = Assembly.GetExecutingAssembly();
//Ensure you include additional folder information before filename
var resourceName = "Namespace.FolderName.txtfile.txt";
using (Stream stream = assembly.GetManifestResourceStream(resourceName))
using (StreamReader sr = new StreamReader(stream))
{
string line;
while ((line = sr.ReadLine()) != null)
{
//As an example, I'm using a CSV textfile
//So want to split my strings using commas
string[] fields = line.Split(',');
string item = fields[0];
string item1 = fields[1];
}
sr.Close();
}