コード例 #1
0
ファイル: Service1.cs プロジェクト: Bogdan-101/CSharp
            // создание файлов
            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);
                });
            }