如何从 Lync 中嵌入的 Silverlight 读取文件?
我正在尝试从 Silverlight 读取 XML 文件。我做得很完美,我从 xap 作为桌面应用程序读取它(在 VS 2010 上运行)。
但是,当我从 Lync 2010 的 CWE(对话窗口扩展)加载 silverlight 时,它返回未处理的错误。
作为应用程序,我这样做: 将 xml 文件作为参考添加到解决方案中 我将 xml 下载为 uri 下载完成后,我阅读了该文件。
任何帮助或提示将不胜感激。
我使用的代码是这样的:
private void button1_Click_1(object sender, RoutedEventArgs e)
{
//this.MessageLabel_SET("Loading Languages...");
WebClient xmlClient = new WebClient();
xmlClient.DownloadStringCompleted += new DownloadStringCompletedEventHandler(XMLFileLoaded);
xmlClient.DownloadStringAsync(new Uri(textBox1.Text, UriKind.RelativeOrAbsolute));
}
void XMLFileLoaded(object sender, DownloadStringCompletedEventArgs e)
{
string XmlString = e.Result; // Got all your XML data in to a string
Main_Language.Read_XML(XmlString);
Main_Language.Load_Index_From_XML();
LanguageSelector.ItemsSource = Main_Language.Language_Indexes;
LanguageSelector.IsEnabled = true;
sendData.IsEnabled = true;
//MessageLabel_SET("Language Loaded");
}
那么,我如何从 Silverlight 4 中的 CWE Lync 2010 应用程序读取外部文件?
I'm trying to read a XML file from Silverlight. I do it perfectly and I read it from xap as a desktop application (running on VS 2010).
But when I load the silverlight from CWE (Conversation Window Extension) from Lync 2010, it returns an unhandled error.
As application, i do this:
Add as reference the xml file to the solution
I download the xml as an uri
When download is complete, i read the file.
Any help or tip will be preciated.
The code that im using is this:
private void button1_Click_1(object sender, RoutedEventArgs e)
{
//this.MessageLabel_SET("Loading Languages...");
WebClient xmlClient = new WebClient();
xmlClient.DownloadStringCompleted += new DownloadStringCompletedEventHandler(XMLFileLoaded);
xmlClient.DownloadStringAsync(new Uri(textBox1.Text, UriKind.RelativeOrAbsolute));
}
void XMLFileLoaded(object sender, DownloadStringCompletedEventArgs e)
{
string XmlString = e.Result; // Got all your XML data in to a string
Main_Language.Read_XML(XmlString);
Main_Language.Load_Index_From_XML();
LanguageSelector.ItemsSource = Main_Language.Language_Indexes;
LanguageSelector.IsEnabled = true;
sendData.IsEnabled = true;
//MessageLabel_SET("Language Loaded");
}
So, how can i read an external file from a CWE Lync 2010 app in Silverlight 4?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这可以通过使用独立存储文件来完成。
您读取 XML,然后将内容(而不是文件)复制到独立的存储文件,等等。您可以对“下载”执行相同的操作,您必须在读取隔离存储文件后创建文件。
This can be done by using Isolated Storage File.
You read the XML, then copy the content, not the file, to isolated storage file, and so on. You can do the same for 'download', you must create the file after read the isolated storage file.