Exemplo n.º 1
0
        public static UserData LoadUserData()
        {
            UserData loadingData = new UserData();

            try
            {
                XmlSerializer xs = new XmlSerializer(typeof(UserData));
                XmlReader xr = XmlReader.Create(UserDataPath);
                if (xs.CanDeserialize(xr))
                {
                    loadingData = (UserData)xs.Deserialize(xr);
                }
                xr.Close();
            }
            catch (Exception ex)
            {
                String Date = DateTime.Now.ToShortDateString();
                String Time = DateTime.Now.ToShortTimeString();
                File.AppendAllText(ErrorLogPath, "\r\n" + Date + " " + Time + "\t" + ex.Message);
            }

            if (loadingData == null)
            {
                loadingData = new UserData();
            }
            else
            {
                while(loadingData.lastWallpaperPath.Count > 1)
                {
                    loadingData.lastWallpaperPath.RemoveAt(0);
                }
            }
            return loadingData;
        }
Exemplo n.º 2
0
 private void InitUserData()
 {
     User = UserData.LoadUserData();
 }