void WriteFile(bool overWriteExistingFile) { tbkFeedback.Text = ""; tbkFeedback.Background = new SolidColorBrush(Color.FromRgb(255, 255, 255)); EncodingEntity encodingEntity = (EncodingEntity)cmbEncoding.SelectedItem; string content = txtContent.Text.Trim(); DirectoryInfo di = new DirectoryInfo(AssetPath); string fileName = txtNewFileName.Text.Trim(); if (fileName.Length == 0) { ShowFeedback($"Bestandsnaam opgeven", false); return; } try { StreamWriterService.WriteStringToFile(content, di.FullName, fileName, encodingEntity.CharacterSet, overWriteExistingFile); GetFilesInAssets(); cmbFiles.SelectedItem = fileName; btnReadFile_Click(null, null); ShowFeedback($"Bestand {fileName} werd succesvol weggeschreven in {encodingEntity.CharacterSetName}", true); } catch (Exception ex) { ShowFeedback(ex.Message); } }
private void btnReadFile_Click(object sender, RoutedEventArgs e) { txtContent.Text = ""; tbkFeedback.Text = ""; tbkFeedback.Background = new SolidColorBrush(Color.FromRgb(255, 255, 255)); string fileName = (string)cmbFiles.SelectedItem; EncodingEntity encodingEntity = (EncodingEntity)cmbEncoding.SelectedItem; DirectoryInfo di = new DirectoryInfo(AssetPath); try { txtContent.Text = StreamReaderService.ReadFileToString(di.FullName, fileName, encodingEntity.CharacterSet); ShowFeedback($"Bestand {fileName} werd succesvol gelezen", true); } catch (Exception ex) { ShowFeedback(ex.Message); } }