void LoadChannelInfo() { mCurrentChannelsData = null; XmlSerializer serializer = new XmlSerializer(typeof(BtvChannelInfo.BtvChannelList)); StreamReader reader = new StreamReader(System.IO.Path.GetDirectoryName(Application.ExecutablePath) + @"\" + mIni.IniReadValue("Config", "Channel_Info")); mCurrentChannelsData = (BtvChannelInfo.BtvChannelList)serializer.Deserialize(reader); reader.Close(); }
void SaveChannelInfo() { BtvAllJsonData.BtvAllData result; BtvChannelInfo.BtvChannelList ChannelsData = new BtvChannelInfo.BtvChannelList(); ChannelsData.ChannelList = new List <BtvChannelInfo.ChannelInfo>(); using (WebClient client = new WebClient()) { string url = mIni.IniReadValue("Config", "Channel_URL"); var htmlData = client.DownloadData(url); var htmlCode = Encoding.UTF8.GetString(htmlData); result = JsonConvert.DeserializeObject <BtvAllJsonData.BtvAllData>(htmlCode); } for (int i = 0; i < result.channels.Count; i++) { BtvChannelInfo.ChannelInfo info = new BtvChannelInfo.ChannelInfo(); info.ChannelName = result.channels[i].channelName; info.ChannelNo = result.channels[i].channelNo; info.ServiceId = result.channels[i].serviceId; info.ChannelId = result.channels[i].serviceId; ChannelsData.ChannelList.Add(info); } XmlSerializer ser = new XmlSerializer(typeof(BtvChannelInfo.BtvChannelList)); using (FileStream fs = new FileStream(System.IO.Path.GetDirectoryName(Application.ExecutablePath) + @"\" + mIni.IniReadValue("Config", "Channel_Info"), FileMode.Create)) { ser.Serialize(fs, ChannelsData); } MessageBox.Show("채널 데이터 저장 완료"); }