Development by Davis

Headlines

domingo, 20 de enero de 2013

Development by Davis

Development by Davis


WinRT: getting a reference to files in the project

Posted: 18 Jan 2013 01:29 AM PST

In Windows Store Apps, you might often need to get a reference to some files that you included in the application package via managed code. To accomplish this, you need an instance of the System.Uri and using a new format that is specific to WinRT. For instance, supposing you have an image file inside a folder called Images of your project, in managed code you get a reference like this:

Dim img As New Uri("ms-appx:///ProjectName/Images/MyImage.png")  

You use the msappx:/// format followed by the root namespace, the folder name (optional), and the file name. It is important to specify the root namespace (even though not mandatory) because in this way you will be able to reference other items belonging to other projects in the solution, which are still part of the application package.

Alessandro

No hay comentarios:

Publicar un comentario