private static void MoveDir(string srcDir, string targDir) { logger.Info("Moving {0} to {1}", srcDir, targDir); try { int retries = 60; while ((Directory.Exists(srcDir)) && (retries > 0)) { try { // Try to rename it Directory.Move(srcDir, targDir); //must have worked break; } catch { retries--; System.Threading.Thread.Sleep(1000); if (retries <= 0) { throw; } } } } catch (Exception ex) { logger.Info("In DeployP4TestServer, Directory.Move failed: {0}", ex.Message); // rename failed, try to clobber it (can be slow so last resort) Utilities.ClobberDirectory(srcDir); } }
public static void AssemblyCleanup() { Utilities.LogAllTestsFinish(); foreach (var dir in dirsToCleanup) { logger.Info("Removing {0}", dir); //test directory exists try { // try to delete it Directory.Delete(dir, true); } catch { // simple delete failed, try to clobber it (can be slow so last resort) Utilities.ClobberDirectory(dir); } } }
private static void DelDir(string dirPath) { if (!Directory.Exists(dirPath)) { return; } try { Directory.Delete(dirPath, true); } catch { try { // delete failed, try to rename it Directory.Move(dirPath, string.Format("{0}-{1}", dirPath, DateTime.Now.Ticks)); } catch { // rename failed, try to clobber it (can be slow so last resort) Utilities.ClobberDirectory(dirPath); } } }