Reputation: 786
I created a directory named "MyFolder" and wrote some text files there. Now, I want delete that directory and I am using the following code:
public void DeleteDirectory(string directoryName)
{
try
{
using (IsolatedStorageFile currentIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication())
{
if (!string.IsNullOrEmpty(directoryName) && currentIsolatedStorage.DirectoryExists(directoryName))
{
currentIsolatedStorage.DeleteDirectory(directoryName);
textBox1.Text = "deleted";
}
}
}
catch (Exception ex)
{
// do something with exception
}
}
I tried with
DeleteDirectory("MyFolder")
DeleteDirectory("IsolatedStore\\MyFolder")
however it didn't delete that directory. Any idea to solve that?
Upvotes: 1
Views: 513
Reputation: 25116
Have you deleted all of the contents of that directory?
says (although it isn't the windows phone version of the documentation):
A directory must be empty before it is deleted. The deleted directory cannot be recovered once deleted.
The Deleting Files and Directories example demonstrates the use of the DeleteDirectory method.
Upvotes: 2