IsolatedStorageFile.DeleteDirectory works with empty directories only.
Usage:
I wrote the method for recursive deleting content of the directory:
using System.IO.IsolatedStorage;
. . .
public void DeleteDirectory(IsolatedStorageFile
fs, String dirName)
{
String
pattern = dirName + @"\*";
String[]
files = fs.GetFileNames(pattern);
foreach
(String fName in
files)
{
fs.DeleteFile(Path.Combine(dirName, fName));
}
String[]
dirs = fs.GetDirectoryNames(pattern);
foreach
(String dName in
dirs)
{
DeleteDirectory(fs, Path.Combine(dirName, dName));
}
fs.DeleteDirectory(dirName);
}
using
(IsolatedStorageFile fs = IsolatedStorageFile.GetUserStoreForApplication())
{
DeleteDirectory(fs, @"\Projects"); // directory "Projects" in the root will be deleted
DeleteDirectory(fs, @"\Projects"); // directory "Projects" in the root will be deleted
}
No comments:
Post a Comment