tags:

views:

194

answers:

1
+1  Q: 

Load File in XAP

Hello,

I had a number of CSV files embedded within a Silverlight DLL (as Resource). I need to move these into the XAP (as Content rather than resource). The trouble is Application.GetResourceStream always seems to return null when I try and access the files. I have tried a number of ways to achieve this but can't seem to do it. How do you reference the CSV files from code behind?

Thanks in advance.

+3  A: 

How to Get Files From Resources in Silverlight 2.0

StreamResourceInfo sr = Application.GetResourceStream(new Uri("MyImage.png", UriKind.Relative));

BitmapImage bmp = new BitmapImage();

bmp.SetSource(sr.Stream);

JustinAngel
Perfect. The slash at the start was my issue.
kouPhax
Fancy seeing you here, Justin - I always screw the slash up as well. +1 is obligatory!
Jeff Wilcox