---------------------- Windows Phone 7手机开发、.Net培训、期待与您交流! ----------------------
说到历史信息,就需要通过某种方法来保存历史信息。
常用的方法有,配置文件,注册表,数据库。
当数据量比较小时,用数据库就不划算了。
下面来看一下用ini配置文件来实现保存历史信息。
读写配置文件需要用到两个API函数
[DllImport("kernel32")]
private static extern long WritePrivateProfileString(string section, string key, string val, string filePath);
[DllImport("kernel32")]
private static extern int GetPrivateProfileString(string section, string key, string def, StringBuilder retVal, int size, string filePath);
当需要保存信息的时候可以这样写
WritePrivateProfileString(Section, Key, Value, this.inipath); //section是节名,key是键名,value是要写入的值,this.inipath是要写入的配置文件的路径
读取文件的时候
StringBuilder temp = new StringBuilder(500);
int i = GetPrivateProfileString(Section, Key, "", temp, 500, this.inipath);
return temp.ToString();
这样通过对配置文件的读写就可以得到一个具有历史信息的ComboBox了
---------------------- Windows Phone 7手机开发、.Net培训、期待与您交流! ----------------------详细请查看:http://net.itheima.com/