Beispiel #1
0
        static UserData LoadUserData()
        {
            string fileName = GetAppDataPath("UserData.xml");
            try {
                if (File.Exists(fileName)) {
                    System.Xml.Serialization.XmlSerializer reader = new System.Xml.Serialization.XmlSerializer(typeof(UserData));

                    UserData ud = new UserData();
                    using (System.IO.FileStream file = new System.IO.FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read)) {
                        ud = (UserData)reader.Deserialize(file);
                        file.Close();
                    }

                    return ud;
                }
                return new UserData();
            }
            catch (Exception ex) {
                ErrorHandler.inst().Error(ex);
                return new UserData();
            } finally { }
        }
Beispiel #2
0
 public static UserData inst()
 {
     if (inst_ == null) {
         inst_ = LoadUserData();
     } return inst_;
 }