---------前台代码
<Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
<Button Name="btnRead" Content="读取" HorizontalAlignment="Left" Margin="425,131,0,0" VerticalAlignment="Top" Click="btnRead_Click_1"/>
<Button Name="btnWrite" Content="写入" HorizontalAlignment="Left" Margin="725,131,0,0" VerticalAlignment="Top" Click="btnWrite_Click_1"/>
<Button Name="btnCreate" Content="创建" HorizontalAlignment="Left" Margin="425,233,0,0" VerticalAlignment="Top" Click="btnCreate_Click_1"/>
</Grid>
---------后台代码
private async void btnWrite_Click_1(object sender, RoutedEventArgs e)
{
StorageFolder document = Windows.Storage.KnownFolders.DocumentsLibrary;
StorageFile file = await document.GetFileAsync("旅游计划.txt");
await FileIO.WriteTextAsync(file, "今天的工作计划");
MessageDialog mes = new MessageDialog("写入成功");
await mes.ShowAsync();
}
private async void btnCreate_Click_1(object sender, RoutedEventArgs e)
{
StorageFolder document= Windows.Storage.KnownFolders.DocumentsLibrary;
StorageFile file= await document.CreateFileAsync("旅游计划.txt",CreationCollisionOption.ReplaceExisting);
MessageDialog mes = new MessageDialog(file.Path);
await mes.ShowAsync();
}