Suppose you have a test.xml file built into the assembly. You can use the GetManifestResourceStream method to get a stream pointing to the contents:
class Program { static void Main() { var assembly = Assembly.GetExecutingAssembly(); using (var stream = assembly.GetManifestResourceStream("ProjectName.test.xml")) using (var reader = new StreamReader(stream)) { Console.WriteLine(reader.ReadToEnd()); } } }
Thus, the contents of the file are read into memory. You can also save it to your hard drive and then access it in an absolute path, but this may not be necessary since you already have the contents of the file.
Darin Dimitrov
source share