コード例 #1
0
 public void setConfig(DeviceModel device)
 {
     if (!Directory.Exists(path))//不存在path文件夹
     {
         Directory.CreateDirectory(path);//新建文件夹
     }
     XmlSerializer xmlSerializer = new XmlSerializer(typeof(DeviceModel));
     Stream stream = new FileStream(path + fname, FileMode.Create, FileAccess.Write, FileShare.ReadWrite);
     xmlSerializer.Serialize(stream, device);
     stream.Close();
 }
コード例 #2
0
        public DeviceModel getConfig()
        {
            DeviceModel device = new DeviceModel();

            if (File.Exists(path + fname))
            {
                XmlSerializer xmlSerializer = new XmlSerializer(typeof(DeviceModel));
                Stream stream = new FileStream(path + fname, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                device = (DeviceModel)xmlSerializer.Deserialize(stream);
            }

            return device;
        }
コード例 #3
0
 public void setConfig(DeviceModel device) 
 {
     dd.setConfig(device);
 }