GetResourceStream Method (StreamResourceInfo, Uri)
Collapse the table of content
Expand the table of content

Application.GetResourceStream Method (StreamResourceInfo, Uri)

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

Returns a resource file from a location in the specified zip package.

Namespace:  System.Windows
Assembly:  System.Windows (in System.Windows.dll)

'Declaration
Public Shared Function GetResourceStream ( _
	zipPackageStreamResourceInfo As StreamResourceInfo, _
	uriResource As Uri _
) As StreamResourceInfo

Parameters

zipPackageStreamResourceInfo
Type: System.Windows.Resources.StreamResourceInfo
A StreamResourceInfo that contains the zip package stream with the desired resource file.
uriResource
Type: System.Uri
A relative URI that identifies the resource file to be extracted from the zip package. The URI is relative to the application package and does not need a leading forward slash.

Return Value

Type: System.Windows.Resources.StreamResourceInfo
A StreamResourceInfo that contains the stream for the desired resource file or Nothing if the specified resource cannot be found.

ExceptionCondition
ArgumentException

The application class is not initialized.

-or-

uriResource is an absolute URI.

ArgumentNullException

zipPackageStreamResourceInfo is Nothing.

-or-

uriResource is Nothing.

The GetResourceStream(StreamResourceInfo, Uri) method provides more flexibility than GetResourceStream(Uri) by allowing you to extract a resource file from an arbitrary zip package.

The following example shows how to extract an image resource file from a zip package.


<!--ContentPanel - place additional content here-->
<StackPanel x:Name="stackPanel" Grid.Row="1"/>



Imports Microsoft.Phone.Controls
' Uri
Imports System.IO
' Stream
Imports System.Windows
' Application
Imports System.Windows.Controls

Imports System.Windows.Media.Imaging

Imports System.Net

Imports System.Windows.Resources

Partial Public Class PageLong
    Inherits PhoneApplicationPage
    Public Sub New()
        InitializeComponent()

        ' Specify the zip package with the image resource to get.
        Dim imageSri As StreamResourceInfo =
            Application.GetResourceStream(Application.GetResourceStream(New Uri(
                    "ZIPPackageWithImage.zip", UriKind.Relative)),
                    New Uri("ImageInZipPackage.png", UriKind.Relative))
        ' Convert the stream to an Image.
        Dim bi As New BitmapImage()
        bi.SetSource(imageSri.Stream)
        Dim img As New Image()
        img.Source = bi
        Me.stackPanel.Children.Add(img)
    End Sub

End Class



Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

Show:
© 2017 Microsoft