Using resource file in c#

  • Thread starter Thread starter asharda
  • Start date Start date
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.
 
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.
 
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

Back
Top