예제 #1
0
파일: App.cs 프로젝트: DelLitt/opmscoral
 private void saveSettingButton_Click(object sender, EventArgs e)
 {
     SaveFileDialog saveFileDialog = new SaveFileDialog();
     DialogResult result = saveFileDialog.ShowDialog();
     if(result == DialogResult.Cancel) return;
     //var streamWriter = File.Open(Application.LocalUserAppDataPath + @"\tablePrefs.obj", FileMode.Create);
     var streamWriter = File.Open(saveFileDialog.FileName, FileMode.Create);
     BinaryFormatter xmlSerializer;
     using (streamWriter)
     {
         xmlSerializer = new BinaryFormatter();
         TablePreferenceSettings tablePreferenceSettings  = new TablePreferenceSettings
                                                                {
                                                                    TablePreferences = _tablePreferences
                                                                };
         xmlSerializer.Serialize(streamWriter, tablePreferenceSettings);
     }
     MessageBox.Show("OK!");
 }
예제 #2
0
        public void SaveTablePreferencesSetting(string path, List<ApplicationPreferences> preferences)
        {
            string projectPath = EnsureProjectPath(path);

            //var streamWriter = File.Open(Application.LocalUserAppDataPath + @"\tablePrefs.obj", FileMode.Create);
            var streamWriter = File.Open(projectPath +@"\" + TablePreferencesFile, FileMode.Create);
            BinaryFormatter binaryFormatter;
            using (streamWriter)
            {
                binaryFormatter = new BinaryFormatter();
                TablePreferenceSettings tablePreferenceSettings = new TablePreferenceSettings
                {
                    TablePreferences = preferences
                };
                binaryFormatter.Serialize(streamWriter, tablePreferenceSettings);
            }
        }