从绝对uri读取流
Read stream from absolute uri
如何从绝对 uri 获取资源流。
当我运行下面的代码时,我在 sri 中得到 null。
StreamResourceInfo sri = Application.GetResourceStream(new Uri("http://----", UriKind.RelativeorAbsolute));
BitmapImage src = new BitmapImage();
src.SetSource(sri.Stream);
// Get WriteableBitmap
WriteableBitmap bitmap = new WriteableBitmap(src);
非常感谢任何帮助。
GetResourceStream
方法不适用于 http 请求。 See the documentation here.
Returns a resource file from a location in the application package.
uriResource
Type: System.Uri
A relative URI that identifies the resource file to be loaded. If the file has a Build Action of Content, the URI is relative to the application package and you should not use a leading forward slash. If the file has a
Build Action
of Resource
, you can use a leading forward slash, but it is not required.
资源数据是编译成你的数据 assembly/package
基本上,您可以通过该方法加载两种类型的资源:
Files Embedded in the application assembly in the application package
Uri("/Application;component/EmbeddedInApplicationAssembly.png")
应用程序包中包含的文件
Uri("IncludedInApplicationPackage.png");
您要找的是HttpClient
如何从绝对 uri 获取资源流。
当我运行下面的代码时,我在 sri 中得到 null。
StreamResourceInfo sri = Application.GetResourceStream(new Uri("http://----", UriKind.RelativeorAbsolute));
BitmapImage src = new BitmapImage();
src.SetSource(sri.Stream);
// Get WriteableBitmap
WriteableBitmap bitmap = new WriteableBitmap(src);
非常感谢任何帮助。
GetResourceStream
方法不适用于 http 请求。 See the documentation here.
Returns a resource file from a location in the application package.
uriResource Type:
System.Uri
A relative URI that identifies the resource file to be loaded. If the file has a Build Action of Content, the URI is relative to the application package and you should not use a leading forward slash. If the file has aBuild Action
ofResource
, you can use a leading forward slash, but it is not required.
资源数据是编译成你的数据 assembly/package
基本上,您可以通过该方法加载两种类型的资源:
Files Embedded in the application assembly in the application package
Uri("/Application;component/EmbeddedInApplicationAssembly.png")
应用程序包中包含的文件
Uri("IncludedInApplicationPackage.png");
您要找的是HttpClient