Winphone 沒有直接刪除文件夾的接口(由於文件夾不爲空是刪除不了的),因此要本身實現
public static void DeleteDirectoryRecursively(this IsolatedStorageFile storageFile, String dirName){
String pattern = dirName + @"\*";
String[] files = storageFile.GetFileNames(pattern);
foreach (var fName in files)
{
storageFile.DeleteFile(Path.Combine(dirName, fName));
}
String[] dirs = storageFile.GetDirectoryNames(pattern);
foreach (var dName in dirs)
{
DeleteDirectoryRecursively(storageFile, Path.Combine(dirName, dName));
}
storageFile.DeleteDirectory(dirName);}
http://stackoverflow.com/questions/18422331/easy-way-to-recursively-delete-directories-in-isolatedstorage-on-wp7-8 ide