示例#1
0
        public static MyFavorits Read()
        {
            MyFavorits _s = new MyFavorits();
            string XmlFile = WebradioData.XmlFavorites;

            try
            {
              if (!File.Exists(XmlFile))
              {
            MyFavorit mf = new MyFavorit("Favorites", true, new List<string>());
            _s.FavoritList.Add(mf);
            MyFavorits.Write(_s);
              }

              stream = new FileStream(XmlFile, FileMode.Open);
              serializer = new XmlSerializer(typeof(MyFavorits));
              _s = (MyFavorits)serializer.Deserialize(stream);
            }
            finally
            {
              stream.Close();
              serializer = null;
            }
            return _s;
        }
示例#2
0
        public static MyFavorits Read()
        {
            MyFavorits _s      = new MyFavorits();
            string     XmlFile = WebradioData.XmlFavorites;

            try
            {
                if (!File.Exists(XmlFile))
                {
                    MyFavorit mf = new MyFavorit("Favorites", true, new List <string>());
                    _s.FavoritList.Add(mf);
                    MyFavorits.Write(_s);
                }

                stream     = new FileStream(XmlFile, FileMode.Open);
                serializer = new XmlSerializer(typeof(MyFavorits));
                _s         = (MyFavorits)serializer.Deserialize(stream);
            }
            finally
            {
                stream.Close();
                serializer = null;
            }
            return(_s);
        }