Read files in Windows Phone 7 – Education Career Blog

I’m trying to open a file in Windows Phone 7, but it says it doesn’t exist. Here’s the code I’m trying:

IsolatedStorageFile file = IsolatedStorageFile.GetUserStoreForApplication();
bool test = file.FileExists("\\ClientBin\\clubs.xml");

And in my project I added a folder called ClientBin, and the clubs.xml is in there. The clubs.xml file properties are:

Build action: Content
Copy to Output Directory: Copy always

I’m not sure what I’m doing wrong. You can see what I have in this screenshot.

Thanks!

,

When you ship a file with your application, it doesn’t get stored in IsolatedStorage. You need use the conventional way of opening a file that ships with the XAP –

XDocument xdoc = XDocument.Load("ClientBin/customers.xml");
var customers = from query in xdoc.Descendants("Customer")
                select new Customer
                {
                   Name = (string)query.Element("Name"),
                   Employees = (int)query.Element("Employees"),
                   Phone = (string)query.Element("Phone")
                };


// Data bind to listbox
listBox1.ItemsSource = customers;

HTH, indyfromoz

Leave a Comment