c# - Accessing Resources at Runtime -


I have an XML file that is included as part of a Silverlight 4.0 project which I want to access at runtime. I have a saved file in the resource named directory with the build action set on the copy of the output directory set to "directory" and "do not copy". If I uncompress the XAP file, then I'm seeing an XML file in the place that I expect, but I'm not sure how to reference it with the code. I currently have the following:

  stream stream = system. Refalbank Assembly. GetExecutingAssembly () GetManifestResourceStream (@ "/ AssemblyName; Component / Resource / MyFile.xml")   

Unfortunately, the stream is zero after running the above code, in addition to the path mentioned above, "I / Resources / MyFile. XML "," / MyFile .xml "and" MyFile .xml ", but all of them experience the same behavior.

What is the correct way to access an XML file embedded in a Silverlight application as a resource?

A resource creation function "content" just gets embedded in the EXP file, as well as the application's With relative directory structure. It does not get embedded in the assembly as a resource.

When the action is set to prepare "content", then you should be able to load the file in some way (or whatever is in line with your requirements): < P> XElement.Load (

The method you are currently using (using the resource stream) is for embedded resources (whose construction works on "processing" Is set)). And for those people, although I have not tried so far if your method works, then you can usually

  Application.GetResourceStream    / Html>

Comments