I'm trying to read xml files from assembly, this is my code:
private Assembly testAssembly;
private void button1_Click(object sender, EventArgs e)
{
string testfile = "stack.xml";
String testfileName = string.Format("{0}.{1}", testAssembly.GetName().Name, testfile);
using (Stream stream = testAssembly.GetManifestResourceStream(testfileName))
{
using (StreamReader sr = new StreamReader(stream))
{
var value = sr.ReadToEnd();
Console.WriteLine("The read file is {0}", value);
}
}
}
I've got a problem on this line:
String testfileName = string.Format("{0}.{1}", testAssembly.GetName().Name,
testfile);
Null ref exception unhandled, it says null. Any help???