Q:

Advantages and usefulness of adding an XML file to a Visual Studio 2008 project

What is the advantage of adding XML files to a visual studio 2008 project (windows form app project for example).
Once added to the project, how could I refer to this XML to use it in a class in the same project?  In this case, I would be sending it as a query to a web service.

A:

If you want to use the XML in some form, you could mark it as a "embedded resource" in the properties window, and then access it from your code like so:
Assembly a = Assembly.GetExecutingAssembly();
if(a != null)
{
  Stream s = a.GetManifestResourceStream(typeof(yourType), "YourXmlName.xml");

  if (s != null)
  {
    String xmlContents = new StreamReader(s).ReadToEnd();
  }
}

Once you're done, you have the XML file's contents in "xmlContents", if all goes well.
Marc

