您好我正在为Windows 10开发UWP(通用Windows平台)应用程序,但遇到了一个问题。我无法弄清楚如何在txt文件中的新行上写入数据,因为我写的数据只是覆盖了第一行的数据。非常感谢任何帮助!欢呼声。
写入/读取代码低于Writing to and reading from a text file - C# Windows Universal Platform App Windows 10
private async void SaveButton_Click(object sender, RoutedEventArgs e)
{
//Create the text file to hold the data
Windows.Storage.StorageFolder storageFolder = Windows.Storage.ApplicationData.Current.RoamingFolder;
Windows.Storage.StorageFile ticketsFile = await storageFolder.CreateFileAsync("tickets.txt", Windows.Storage.CreationCollisionOption.ReplaceExisting);
string ingredients = IngredientBox.Text;
//Write data to the file
await Windows.Storage.FileIO.WriteTextAsync(ticketsFile, ingredients);
//read file
string savedTickets = await Windows.Storage.FileIO.ReadTextAsync(ticketsFile);
var path = Windows.Storage.ApplicationData.Current.RoamingFolder.Path;
StepsBox.Text = path;
}