public void DeleteEnlistment() { // Use cmd.exe to delete the enlistment as it properly handles tombstones // and reparse points CmdRunner cmdRunner = new CmdRunner(); bool enlistmentExists = Directory.Exists(this.EnlistmentRoot); int retryCount = 0; while (enlistmentExists) { string output = cmdRunner.DeleteDirectory(this.EnlistmentRoot); enlistmentExists = Directory.Exists(this.EnlistmentRoot); if (enlistmentExists) { ++retryCount; Thread.Sleep(500); try { if (retryCount > 10) { retryCount = 0; throw new DeleteFolderFailedException(output); } } catch (DeleteFolderFailedException) { // Throw\catch a DeleteFolderFailedException here so that developers who are running the tests // and have a debugger attached can be alerted that something is wrong } } } }