Beispiel #1
0
            // создание файлов
            private void Watcher_Created(object sender, FileSystemEventArgs e)
            {
                ThreadPool.QueueUserWorkItem(async state =>
                {
                    string fileName = e.Name;
                    string filePath = e.FullPath;
                    Console.WriteLine(fileName);

                    string fileEvent = "создан";
                    Regex regex      = new Regex(parsedOptions.options.PathsOptions.Regex);
                    Console.WriteLine(fileName + " ||| " + regex.IsMatch(fileName));
                    if (regex.IsMatch(fileName))
                    {
                        RecordEntry("вошли", fileName);
                        await MyFile.EncryptFile(fileName, filePath, parsedOptions.options.EncryptingOptions.Key);

                        await MyFile.CompressAndMove(fileName, filePath, parsedOptions.options.PathsOptions.TargetPath, parsedOptions.options.CompressOptions.Extension);

                        await MyFile.DecompressFileToTargetDir(fileName, filePath, parsedOptions.options.CompressOptions.Extension);

                        string newPath = MyFile.GetPathOfFileInTargetDir(fileName);
                        newPath       += fileName;

                        await MyFile.DecryptFile(fileName, newPath, parsedOptions.options.EncryptingOptions.Key);
                    }

                    RecordEntry(fileEvent, fileName);
                });
            }