Reputation: 11662
I am trying to load a resource that I have added to my project, and it tells me:
Illegal characters in path.
Now, the name of the resource is: ShortcutList.txt
. I don't see anything illegal about that. And the code I'm using is:
public void InitShortcuts()
{
try
{
string s = File.ReadAllText(Properties.Resources.ShortcutList);
if (!String.IsNullOrEmpty(s))
{
MessageBox.Show(s);
}
}
catch (Exception exception)
{
MessageBox.Show(exception.Message);
}
}
But as I said above it just tells me that there are illegal characters in the path. How? It's not like I'm screwing up the path or anything.
I have set ShortcutList.txt as Embedded Resource and 'Copy if newer' (I've also tried every other option in that list!).
Any ideas what I might be doing wrong?
Upvotes: 0
Views: 162
Reputation: 1449
Just do something like this:
List<string> list = Resources.ShortcutList.Split(new[] { Environment.NewLine }, StringSplitOptions.None).ToList();
You can have your build action set to "Resource", and Copy to output to "Do not copy". It should work.
Upvotes: 1