Adding files to WP7 isolated storage from Visual Studio?

后端 未结 3 586
再見小時候
再見小時候 2021-01-06 07:39

I\'m working on an Windows Phone 7 app where I\'m going to show ATM\'s nere your location with bing maps.

I have an xml-file with addresses and gps coordinates. But

3条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-06 08:14

    Files listed as content in the Visual Studio project are copied to the generated XAP file (which is analogous to a ZIP file). They are not copied to isolated storage.

    In the case of an XML file, you can call XmlReader.Create with the path to the file as argument, as follows:

    using (XmlReader reader = XmlReader.Create("path/to/file.xml"))
    {
        // read XML file here
    }
    

    Or you can also call Application.GetResourceStream and use the Stream property of the returned StreamResourceInfo object:

    StreamResourceInfo sri = Application.GetResourceStream(
        new Uri("path/to/file.xml", UriKind.Relative));
    // read XML file here from sri.Stream, e.g. using a StreamReader object
    

提交回复
热议问题