//public static void DeleteFromFlash() //{ // // Data recovering and storing must be kept in pairs. // // Calling Recover without setting Target frees the FLASH completely from this EWR. // ExtendedWeakReference.Recover(typeof(Options), 0); //} //public static void RestoreLastSaved() // Use this method to rewrite current settings using last saved data. //{ // // First, mark the stored data as unrecovered so we can Recover them. // optionsReference.PushBackIntoRecoverList(); // // Try to recover them, but do not create them if they do not exist. // ExtendedWeakReference restoreReference = ExtendedWeakReference.Recover(typeof(Options), 0); // if (restoreReference != null && restoreReference.Target != null) // { // options = (Options)restoreReference.Target; // If they do, use them to refresh current settings. // restoreReference.PushBackIntoRecoverList(); // Since we found the data, we have to put them back. // } // else // Debug.Print("Could not restore settings."); //} public static Options LoadFromSD(string root) { Options res = new Options(); byte[] data = DriveManager.LoadFromSD(root + fileName); if (data == null) res.SaveToSD(root); else res = Options.FromByteArray(data); return res; }