private void NewFileCopy_Click(object sender, RoutedEventArgs e) { if (CheckItemsListContent() == false) { MessageBox.Show("List is empty"); } else { string[] tempText = TXTtoObservableCollection.ReturnOnlyLines(filePath); string tempName = CreateFileName.Method(); string tempPath = "saves/" + tempName + ".txt"; WorkPage workPage = new WorkPage(tempPath, mp, tempText); workPage.ItemsCollection = TXTtoObservableCollection.fillingMethod(tempText); mp._mainWindow.Main.Content = workPage; string textToFile = ObservableCollectionToTXT.Method(workPage.ItemsCollection); using (StreamWriter sw = File.CreateText(tempPath)) { sw.Write(textToFile); sw.Close(); } DataGridView.ItemsSource = ItemsCollection; MessageBox.Show("Successfully created new list named: " + tempName); } }
public WorkPage(MainPage mainPage) // New page { InitializeComponent(); DataContext = _vm; filePath = "saves/" + CreateFileName.Method() + ".txt"; StreamWriter sw = File.CreateText(filePath); sw.Close(); ItemsCollection = TXTtoObservableCollection.Method(filePath); DataGridView.ItemsSource = ItemsCollection; mp = mainPage; }