zoukankan      html  css  js  c++  java
  • 在wp7中读取XML的配置文件,Content与Resource的区别

    在一个WP7的项目中,需要读取一个配置文件,这个配置文件无需改动,直接读取就可以。可以用以下的方式来实现读取:
    在项目中添加Levels.xml文件,格式如下:



    BuildAction设置为Content,然后在代码中读取:


    这样生成xap后,用winrar解压缩就可以看到这个Levels.xml文件,有时候这样不太安全,可以将其编译到dll中。将BuildAction设置成Resource就可以将文件编译到dll里了,初学WP7的话很容易遇到图片无法显示的问题,就是因为图片一般要设置成Content,而不是Resource。

    设置成Resource以后就不能直接这样了

    可以写完整的Uri路径,或者读取Stream,用以下的方法:(这两种都可以)



    这样编译出来的xap中就看不到这个xml文件了,已经被编译到dll里了。

    除了用这样的读取方式外,还可以直接用xml序列化的方式:比如:

    参考以下文章:
    http://blog.csdn.net/lee353086/article/details/6674095
    http://www.silverlightchina.net/html/zhuantixilie/winphone7/2010/1207/3966.html?1292140571
    http://www.cnblogs.com/tianyutingxy/archive/2011/02/27/1966267.html

  • 相关阅读:
    Unity The Method Signature Matching Rule
    Unity The Property Matching Rule
    Unity The Type Matching Rule
    Unity The Custom Attribute Matching Rule
    Unity The Member Name Matching Rule
    Unity No Policies
    Unity The Return Type Matching Rule
    Unity The Parameter Type Matching Rule
    Unity The Namespace Matching Rule
    关于TSQL递归查询的(转)
  • 原文地址:https://www.cnblogs.com/yanxiaodi/p/2296455.html
Copyright © 2011-2022 走看看