读取远程图像文件

时间:2011-11-25 10:38:02

标签: silverlight filesystems

我的问题看似简单,但出于某种原因,我似乎无法解决它。 我需要在Silverlight中基于远程图像文件设置图像。 我知道,Silverlight无法读取客户端文件系统,但服务器文件系统呢?还是另一个远程共享文件系统?

如何让它读取存储在公共场所的.png文件,并将我的Image控件设置为它?

1 个答案:

答案 0 :(得分:1)

这应该有效:

<Image Source="http://example.com/image.png" />

您还应该能够通过以下代码在C#代码中设置Source

BitmapImage bmi = new BitmapImage(new Uri("http://example.com/image.png", UriKind.Absolute));
image.Source = bmi;

这假设您有权在该位置阅读图像。