代码之家  ›  专栏  ›  技术社区  ›  Carlo

在Windows Phone 7中读取文件

  •  1
  • Carlo  · 技术社区  · 14 年前

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

    在我的项目中,我添加了一个名为ClientBin的文件夹,其中包含clubs.xml。clubs.xml文件属性为:

    生成操作:内容

    我不知道我做错了什么。你可以看到我身上的东西 this screenshot .

    谢谢!

    1 回复  |  直到 14 年前
        1
  •  6
  •   indyfromoz    14 年前

    当应用程序附带文件时,它不会存储在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;
    

    HTH,印度弗洛莫兹