예제 #1
0
 public static AuthObject LoadAuth()
 {
     try {
         Directory.CreateDirectory(directory);
         string          path   = directory + "\\AUTH.dld";
         FileStream      file   = new FileStream(path, FileMode.Open);
         BinaryFormatter reader = new BinaryFormatter();
         AuthObject      obj    = (AuthObject)reader.Deserialize(file);
         file.Close();
         return(obj);
     } catch (Exception ex) {
         MessageBox.Show(ex.ToString());
         return(new AuthObject());
     }
 }
예제 #2
0
        public Startup()
        {
            //Check to if auth details exist
            if (Auth.AuthExist())
            {
                AuthObject obj = Auth.LoadAuth();
                new MainWindow(obj.username, obj.key).Show();
                this.Close();
                return;
            }

            //If not, continue
            InitializeComponent();

            Closed += Startup_Closed;
        }
예제 #3
0
 public static void SaveAuth(string username, string key)
 {
     try {
         Directory.CreateDirectory(directory);
         string     path = directory + "\\AUTH.dld";
         FileStream file = new FileStream(path, FileMode.OpenOrCreate);
         AuthObject data = new AuthObject()
         {
             username = username,
             key      = key
         };
         BinaryFormatter writer = new BinaryFormatter();
         writer.Serialize(file, data);
         file.Close();
     } catch (Exception ex) {
         MessageBox.Show(ex.ToString());
     }
 }