在Windows Phone 7中读取文件

Car*_*rlo 1 windows-phone-7

我正在尝试在Windows Phone 7中打开一个文件,但它说它不存在.这是我正在尝试的代码:

IsolatedStorageFile file = IsolatedStorageFile.GetUserStoreForApplication();
bool test = file.FileExists("\\ClientBin\\clubs.xml");
Run Code Online (Sandbox Code Playgroud)

在我的项目中,我添加了一个名为ClientBin的文件夹,clubs.xml就在那里.clubs.xml文件属性是:

构建操作:内容复制到输出目录:始终复制

我不确定我做错了什么.你可以在这个截图中看到我的内容.

谢谢!

ind*_*moz 6

使用应用程序发送文件时,它不会存储在IsolatedStorage中.您需要使用传统方式打开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;
Run Code Online (Sandbox Code Playgroud)

HTH,indyfromoz