예제 #1
0
        private static void ProcessFile(CacheEntryRemovedArguments args)
        {
            Console.WriteLine($"* Cache item removed: {args.CacheItem.Key} because {args.RemovedReason}");

            if (args.RemovedReason == CacheEntryRemovedReason.Expired)
            {
                var fileProcessor = new FileProcessor(args.CacheItem.Key);
                fileProcessor.Process();
            }
            else
            {
                Console.WriteLine($"WARNING: {args.CacheItem.Key} was removed unexpectedly and may not be used.");
            }
        }
예제 #2
0
        private void taskButton_Click(object sender, EventArgs e)
        {
            if (fileListBox.Items.Count == 0 || fileListBox.SelectedIndex == -1)
            {
                MessageBox.Show("Choose item!", "Warning", MessageBoxButtons.OK);
                return;
            }

            FileProcessor fileProcessor = new FileProcessor();
            Stopwatch     stopWatch     = new Stopwatch();

            stopWatch.Start();
            fileProcessor.MakeAnotherFile(fileListBox.SelectedItem.ToString(), $"Processed_{DateTime.Now.ToString("yyyy-MM-dd_hh-mm-ss")}.txt");
            stopWatch.Stop();

            MessageBox.Show($"Success, elapsed time: {((double)stopWatch.ElapsedMilliseconds * 0.001).ToString(CultureInfo.InvariantCulture)}", "Success", MessageBoxButtons.OK);
        }
예제 #3
0
        private static void ProcessDirectory(string directoryPath, string fileType)
        {
            // var allFiles = Directory.GetFiles(directoryPath); // to get all files

            switch (fileType)
            {
            case "TEXT":
                string[] textFiles = Directory.GetFiles(directoryPath, "*.txt");
                foreach (var textFilePath in textFiles)
                {
                    var fileProcessor = new FileProcessor(textFilePath);
                    fileProcessor.Process();
                }
                break;

            default:
                Console.WriteLine($"ERROR: {fileType} is not supported");
                return;
            }
        }
예제 #4
0
        private static void ProcessSingleFile(string filePath)
        {
            var fileProcessor = new FileProcessor(filePath);

            fileProcessor.Process();
        }