XAML 1 단추와 이름이 UserInputTextBox 및 StatusTextBox 인 2 개의 TEXTBOXES에서 생성했습니다. 그럼 난 파일을 열고 파일에 텍스트를 저장하는 MainPage.xaml.cs를 코드에서 만든 :UWP가 파일에 텍스트 저장
FileOpenPicker picker = new FileOpenPicker();
private async void Button_Click(object sender, RoutedEventArgs e)
{
// Set properties on the file picker such as start location and the type
// of files to display.
picker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary;
picker.ViewMode = PickerViewMode.List;
picker.FileTypeFilter.Add(".txt");
// Show picker enabling user to pick one file.
StorageFile result = await picker.PickSingleFileAsync();
if (result != null)
{
try
{
// Use FileIO to replace the content of the text file
await FileIO.WriteTextAsync(result, UserInputTextBox.Text);
// Display a success message
StatusTextBox.Text = "Status: File saved successfully";
}
catch (Exception ex)
{
// Display an error message
StatusTextBox.Text = "Status: error saving the file - " + ex.Message;
}
}
else
StatusTextBox.Text = "Status: User cancelled save operation";
}
을하고 난 UserInputTextBox 텍스트를 작성하는 경우 다음이 텍스트 파일 (.txt)로 될 것입니다하지만 내 문제는 내가 만약 UserInputTextBox 텍스트에 두 번째로 쓰면 첫 번째 텍스트가 두 번째 텍스트로 변경됩니다. 내가 원하는 것은 UserInputTextBox에 텍스트를 써서이 텍스트를 저장해야하고 두 번째 텍스트를 쓰면 두 개의 텍스트가있는 것입니다.