Just like folders, files could also be easily renamed using the RenameAsync
method, which is explained in this recipe.
As an example, you will modify the project from the previous recipe by adding a Rename a file button. Once you click on it, the Notes.txt
file (from the Book
directory) should be renamed Note.txt
.
To see how to rename a given file, perform the following steps:
Add the Rename a file button to the page by modifying the content of the
MainPage.xaml
file as follows:<Page (...)> <StackPanel> (...) <Button Content="Rename a file" HorizontalAlignment="Center" VerticalAlignment="Center" Click="BtnRenameFile_Click" /> <TextBlock x:Name="TxtResult" TextWrapping="Wrap...