在搜索解决方案时,我遇到了各种链接,这些链接讨论了读取ClientBin文件夹中的xml文件。但我想要实现的是,我想读取一个xml文件,该文件在Web项目中不存在,但是包含视图的silverlight项目。
答案 0 :(得分:2)
试试这个:
StreamResourceInfo s = Application.GetResourceStream(new Uri("Directory Under Silverlight Root/FileName.xml", UriKind.Relative));
var sr = new StreamReader(s.Stream);
// do whatever you need to do with the streamreader
while (!sr.EndOfStream)
{
var line = sr.ReadLine();
//do stuff
}
编辑:xml文件的Build Action应为'Content',其Copy to Output Directory应为'Do not copy'