so far:
List<string> names = Properties.Resources.first_names.ToArray().ToList();
produce wrong result,
the txt is like=> "Shirley","Rose","Sean","Jeremy"
so far:
List<string> names = Properties.Resources.first_names.ToArray().ToList();
produce wrong result,
the txt is like=> "Shirley","Rose","Sean","Jeremy"
Use a regex to split on the commas outside of the quotes like so:
var names = Regex.Split(Properties.Resources.first_names, ",(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)");
Then loop over each entry and remove the quotes like so:
for (int i = 0; i < names.Length; i++)
{
names[i] = names[i]Replace("\"", "");
}
To read text file contents from resources and convert to list, try this:
byte[] file = Properties.Resources.myResourceFile;
string text;
using (Stream stream = new MemoryStream(file))
{
using (StreamReader reader = new StreamReader(stream))
{
text = reader.ReadToEnd();
}
}
var names = text.Split(',').ToList();