private void SaveWorkspace() { string wsPath = ""; StreamWriter sw = null; try { SaveFileDialog dialog = new SaveFileDialog { InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop), DefaultExt = ".xml", Filter = "xml Files (*.xml)|*.xml" }; // Get the selected file name and display in a TextBox if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { wsPath = dialog.FileName; WorkSpaceClass sol = m_WorkspaceDoc; sw = new StreamWriter(wsPath); XmlSerializer x = new XmlSerializer(sol.GetType()); x.Serialize(sw, sol); sw.Close(); MessageBox.Show("Save Complete"); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void LoadWorkspace() { WorkSpaceClass temp = new WorkSpaceClass(); OpenFileDialog dialog = new OpenFileDialog { InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop), DefaultExt = ".xml", Filter = "xml Files (*.xml)|*.xml" }; if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { CreateNewSolution(); StreamReader sr = new StreamReader(dialog.FileName); XmlSerializer x = new XmlSerializer(m_WorkspaceDoc.GetType()); temp = x.Deserialize(sr) as WorkSpaceClass; if (temp == null) { return; } m_WorkspaceDoc = temp; MAINTREE_UI.ItemsSource = null; MAINTREE_UI.ItemsSource = m_WorkspaceDoc.p_Solutions; //LostFocuse때 SaveDoc을 하기위함. IMG_LSTVIEW_UI.Focusable = true; IMG_LSTVIEW_UI.Focus(); inner_BottomSelTreeView(); IMG_LSTVIEW_UI.SelectedIndex = 0; MessageBox.Show("Load Complete"); } }