如何读取Silverlight项目中文件夹中的XML文件?
在搜索解决方案时,我遇到了各种各样的链接,其中谈到如何读取ClientBin文件夹中的xml文件。但我想实现的是,我想读取一个xml文件,该文件不在web项目中,而是包含视图的silverlight项目中。尝试以下操作:如何读取Silverlight项目中文件夹中的XML文件?,silverlight,silverlight-4.0,Silverlight,Silverlight 4.0,在搜索解决方案时,我遇到了各种各样的链接,其中谈到如何读取ClientBin文件夹中的xml文件。但我想实现的是,我想读取一个xml文件,该文件不在web项目中,而是包含视图的silverlight项目中。尝试以下操作: StreamResourceInfo s = Application.GetResourceStream(new Uri("Directory Under Silverlight Root/FileName.xml", UriKind.Relative));
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文件的生成操作应为“内容”,其复制到输出目录应为“不复制”