Embedding Resources in Silverlight

This post explains how to embed a resource file in Silverlight and use it. For the example we’ll consider embedding a CSV file and using it.

Copy the file inside the project under the appropriate path. In the properties of the file set the Build Action as Embedded Resource.

The below sample code shows how to access an embedded CSV file.

   1: Stream shareInfo = typeof(ShareInformationManipulation)

   2:                    .Assembly

   3:                    .GetManifestResourceStream("data.csv");

You can read any type of embedded resource as  a Stream.

Advertisement