1

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!

1 Answer 1

6

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

0

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.