private void removeExpiredTask(string directory) { string[] fileList = Directory.GetFiles(directory); int count = fileList.Length - PrintCenterConfiguration.getInstance().NumberOfFileToKeep; if (count > 0) { for (int i = 0; i < count; ++i) { File.Delete(fileList[i]); } } }
private string generateTakeFilePath() { string dirToMonitor = PrintCenterConfiguration.getInstance().DirectoryToMonitor; DateTime now = DateTime.Now; StringBuilder builder = new StringBuilder("task"); builder.Append(now.Year); builder.Append(now.Month.ToString().PadLeft(2, '0')); builder.Append(now.Day.ToString().PadLeft(2, '0')); builder.Append(now.Hour.ToString().PadLeft(2, '0')); builder.Append(now.Minute.ToString().PadLeft(2, '0')); builder.Append(now.Second.ToString().PadLeft(2, '0')); builder.Append(now.Millisecond.ToString().PadLeft(3, '0')); string filename = builder.ToString(); return(dirToMonitor + @"\" + filename + ".xml"); }
private string getNextTaskFile() { string dirToMonitor = PrintCenterConfiguration.getInstance().DirectoryToMonitor; if (!Directory.Exists(dirToMonitor)) { throw new Exception(string.Format("Failed to monitor task directory '{0}' doesn't exsit.", dirToMonitor)); } string[] fileList = Directory.GetFiles(dirToMonitor, "task*.xml", SearchOption.TopDirectoryOnly); if (fileList.Length > 0) { return(fileList[0]); } else { return(string.Empty); } }
private static void initDirectory() { if (!Directory.Exists(PrintCenterConfiguration.getInstance().DirectoryToMonitor)) { Directory.CreateDirectory(PrintCenterConfiguration.getInstance().DirectoryToMonitor); } if (!Directory.Exists(GlobalVariable.getPrintedDirectory())) { Directory.CreateDirectory(GlobalVariable.getPrintedDirectory()); } if (!Directory.Exists(GlobalVariable.getDeletedDirectory())) { Directory.CreateDirectory(GlobalVariable.getDeletedDirectory()); } if (!Directory.Exists(GlobalVariable.getPrintingDirectory())) { Directory.CreateDirectory(GlobalVariable.getPrintingDirectory()); } }