<?xml version="1.0" encoding="gb2312"?>
<ArrayOfVerInfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<VerInfo>
<VerName>5.2.2</VerName>
<VerPath>c:\\adadfa.ext</VerPath>
</VerInfo>
<VerInfo>
<VerName>5.4.2</VerName>
<VerPath>d:\\adadfa.ext</VerPath>
</VerInfo>
</ArrayOfVerInfo>
----------实体类VerInfo.cs-------------
namespace VerList
{
[XmlRoot("Root")] //我把Root改成ArrayOfVerInfo一样的报错
public class VerInfo
{
[XmlElement("VerName")]
public string VerName
{ set; get; }
[XmlElement("VerPath")]
public string VerPath
{ set; get; }
}
}
--------调用addVer.cs------------
namespace VerList
{
public partial class addVer : Form
{
public List<VerInfo> VerInfoList;
public addVer()
{
InitializeComponent();
getXml(System.IO.Directory.GetCurrentDirectory() + @"\ver.xml");
}
public void getXml(string filename)
{
XmlSerializer xs = new XmlSerializer(typeof(List<VerInfo>));
FileStream fs = File.OpenRead(filename);
VerInfoList = xs.Deserialize(fs) as List<VerInfo>;
fs.Dispose();
}
在加粗的这一句报错,麻烦帮偶看看,多谢了。
1 个解决方案
#1
定义ArrayOfVerInfo类,里面包含List<VerInfo> VerInfoList;
#1
定义ArrayOfVerInfo类,里面包含List<VerInfo> VerInfoList;