public static void RotateNow() { try { // close the open logfile CommandLogging.Close(); string root = Path.Combine(Core.BaseDirectory, "Logs"); if (!Directory.Exists(root)) { Directory.CreateDirectory(root); } string[] existing = Directory.GetDirectories(root); DirectoryInfo dir; // rename the commands directory with a date-time stamp dir = Match(existing, "Commands"); if (dir != null) { TimeSpan tx = DateTime.Now - new DateTime(2000, 1, 1); string ToName = String.Format("{0}, {1:X}", DateTime.Now.ToLongDateString(), (int)tx.TotalSeconds); try { dir.MoveTo(FormatDirectory(root, ToName, "")); } catch (Exception ex) { LogHelper.LogException(ex); Console.WriteLine("Failed to move to {0}", FormatDirectory(root, ToName, "")); Console.WriteLine(ex.ToString()); throw (ex); } } // reopen the logfile CommandLogging.Open(); } catch (Exception ex) { LogHelper.LogException(ex); throw (ex); } }