Understanding System.Uri
StreamResourceInfo sri;
sri = App.GetResourceStream(new Uri("WebBrowserIsoStorage;component/Images/textmate.jpg", UriKind.Relative));
using (BinaryReader reader = new BinaryReader(sri.Stream))
{
using (BinaryWriter writer = new BinaryWriter(imageStream))
{
while (sri.Stream.Position < sri.Stream.Length)
开发者_运维问答 {
writer.Write(reader.ReadByte());
}
}
}
What does the WebBrowserIsoStorage;
in the path mean (line 2)?
That uri string is a relative Pack UrI (see Table 2 in the linked page for a similar example).
The first part (WebBrowserIsoStorage
) is the assembly in which the resource (the textmate.jpg image) lives. The second part is the path to the resource within the assembly.
WebBrowserIsoStorage
is the Isolated Storage location for the Web browser.
It means that there is an assembly in the system, that is called WebBrowserIsoStorage
, and by following the component with a path after it, you are trying to access its resources.
精彩评论