void RecursiveDirectoryDelete(Storage storage, string path) { if (path.Length > 0) { path += "/"; } foreach (var subDirectory in storage.GetDirectoryNames(path + "*")) { RecursiveDirectoryDelete(storage, path + subDirectory); } DeleteFiles(storage, path); storage.DeleteDirectory(path); }
public void CanDeleteSubDirectoryWithContents() { storage.CreateDirectory("test"); WriteFile("test/file.txt"); storage.CreateDirectory("test/sub"); WriteFile("test/sub/file.txt"); var directory = new IsolatedStorageDirectory(() => storage); var subDirectory = directory.GetDirectory("test"); subDirectory.Delete(); storage.GetDirectoryNames("*").ShouldBeEmpty(); }
void RecursiveDirectoryDelete(Storage storage, string path) { if (path.Length > 0) path += "/"; foreach (var subDirectory in storage.GetDirectoryNames(path + "*")) { RecursiveDirectoryDelete(storage, path + subDirectory); } DeleteFiles(storage, path); storage.DeleteDirectory(path); }