Renaming a directory
Sometimes, it is necessary to rename an existing folder. You can easily do this using the approach presented in this recipe.
As an example, you will modify the project from the previous recipe by adding a Rename a directory button. Once you click on it, the Book
folder should be renamed New book
. You will also check whether the folder already exists and whether the renaming operation is possible. Otherwise, a suitable message will be presented.
Getting ready
To step through this recipe, you need the project from the previous recipe.
How to do it...
To see how to rename a given directory, perform the following steps:
Add the Rename a directory button to the page by modifying the content of the
MainPage.xaml
file as follows:<Page (...)> <StackPanel> (...) <Button Content="Rename a directory" HorizontalAlignment="Center" VerticalAlignment="Center" ...