/// <summary> /// Загрузка файла с конфигурацией /// </summary> /// <param name="FileName"></param> /// <returns></returns> public static WaveformConfiguration LoadConfiguration(String FileName) { if (System.IO.File.Exists(FileName) == false) { return(null); } WaveformConfiguration conf = null; FileStream stream = null; try { IFormatter formatter = new BinaryFormatter(); stream = new FileStream(FileName, FileMode.Open, FileAccess.Read, FileShare.None); conf = formatter.Deserialize(stream) as WaveformConfiguration; } catch (Exception ex) { } finally { if (stream != null) { stream.Close(); } } return(conf); }
/// <summary> /// Сохранение файла с конфигурацией /// </summary> /// <param name="core"></param> /// <param name="FileName"></param> public static void SaveConfiguration(WaveformCore core, string FileName) { WaveformConfiguration conf = new WaveformConfiguration(core); BinaryFormatter bformatter = new BinaryFormatter(); FileStream file = null; try { file = new FileStream(FileName, FileMode.OpenOrCreate); bformatter.Serialize(file, conf); } catch (Exception ex) { } finally { if (file != null) { file.Close(); } } }