如何:从 XML 文件中读取类数据
来源:互联网 发布:网络与新媒体考研吧 编辑:程序博客网 时间:2024/04/29 14:56
此示例使用 XmlSerializer类的 Deserialize 方法读取存储在名为 IntroToVCS.xml 的示例文件中的对象上的数据。
public class Book{ public string title; static void Main() { Book introToVCS = new Book(); System.Xml.Serialization.XmlSerializer reader = new System.Xml.Serialization.XmlSerializer(introToVCS.GetType()); // Read the XML file. System.IO.StreamReader file= new System.IO.StreamReader("c:\\IntroToVCS.xml"); // Deserialize the content of the file into a Book object. introToVCS = (Book) reader.Deserialize(file); System.Windows.Forms.MessageBox.Show(introToVCS.title, "Book Title"); }}
以下条件可能会导致异常:
路径名可能太长。
- 如何:从 XML 文件中读取类数据
- 如何从XML文件中读取数据绑定到DropDownList
- 从XML文件中读取数据
- 从xml文件中读取出数据
- 如何:从文件中读取 XML
- 如何从property文件中读取数据
- 本文介绍了如何从XML文件中读取数据绑定到DropDownList。
- 从XML文件中读取数据绑定到DropDownList
- 从XML文件中读取数据绑定到DropDownList
- 从XML文件中读取数据绑定到DropDownList
- 从XML文件中读取数据绑定到DropDownList
- 从XML文件中读取数据绑定到DropDownList
- 从xml或yml文件中读取数据
- XML文件中如何读取xxx.properties文件中的数据
- Java, 如何从Excel中读取数据到文件中
- 从文件中读取数据
- 从文件中读取数据
- 从文件中读取数据
- 如何:将类数据写入 XML 文件
- Android数据的四种存储方式SharedPreferences、SQLite、Content Provider和File (一) —— 总览
- linux网络协议栈分析笔记11-路由1-路由缓存
- 职责链设计模式-计算收费有效时间
- 第17天的交易(2013-4-12)(+100) (110)
- 如何:从 XML 文件中读取类数据
- shell脚本里的\r字符。
- Android数据的四种存储方式SharedPreferences、SQLite、Content Provider和File (二) —— SQLite
- HDU1022--Train Problem I
- OpenMP创建线程中的锁及原子操作性能比较
- linux下python学习笔记(一)
- uva10730
- C/C++利用system()创建文件夹,如果已存在,则先删除,再创建--windowsXP
- linux fork函数与vfork函数