I have 3 text files in my solution (they are in the solution explorer) that I need to read in from. I don't want them copied to the output directory and they are marked as Embedded Resources. The path to them is ProjectNamespace.Utility.Names.nameXXX.txt
I need to access them in a class, also in the Names folder:
public RandomName()
{
_prefixParts = PopulateFromFile("AoW.Utility.Names.namePrefix.txt");
_middleParts = PopulateFromFile("AoW.Utility.Names.nameMiddle.txt");
_suffixParts = PopulateFromFile("AoW.Utility.Names.nameSuffix.txt");
}
What is the correct syntax to read in from these files?
Update: Here is the PopulateFromFile
method in case it matters:
private static string[] PopulateFromFile(string path)
{
return File.ReadAllLines(path);
}
Update: I'm attempting to implement the code from this answer: https://stackoverflow.com/a/16901400/1667020
Update: Well, I've gotten it to work at this point:
_prefixParts = PopulateFromFile(@"C:\Users\Owner\Desktop\AoW\AoW\AoW\Utility\Names\namePrefix.txt");
_middleParts = PopulateFromFile(@"C:\Users\Owner\Desktop\AoW\AoW\AoW\Utility\Names\nameMiddle.txt");
_suffixParts = PopulateFromFile(@"C:\Users\Owner\Desktop\AoW\AoW\AoW\Utility\Names\nameSuffix.txt");
How can I make the path local to the project?