Using resource file in c#

A

asharda

Hello,

I have a XML file in VS2008 WPF application for which I have specified
the build action as Resource. Now I want to access that file in my c#
code also. Can anyone please help? I do not want to use embedded
resource as then I am not able to use the xml file data to populate
the Listbox in my XAML code.

Any help will be greately appreciated.

Thanks for your time in advance.
 
J

jp2msft

What's the name of your application?

If it is MyApp, you could use something like this in VS2005 (VS2008 may be
similar):

// after you define XMLfile as needed...
XMLfile = global::MyApp.Properties.Resources.xmlFile;

But, why would you embed an XML file? That should be deployed with your app
in the Application Data or Program Files section. You are talking a lot of
string text to embed into your executable. It is a rather wasteful technique.
 
C

Chris Jobson

I have a XML file in VS2008 WPF application for which I have specified
the build action as Resource. Now I want to access that file in my c#
code also. Can anyone please help? I do not want to use embedded
resource as then I am not able to use the xml file data to populate
the Listbox in my XAML code.

I think that you can use Application.GetResourceStream() .

Chris Jobson
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top