コード例 #1
0
        private async Task processImageFiles(string rootPath, string outputPath)
        {
            string[] extensionsToMatch = { "*.jpg", "*.jpeg", "*.png", "*.gif", "*.bmp", "*.pdf" };
            await Task.Run(async() => {
                FileAttributes attr = File.GetAttributes(rootPath);

                if ((attr & FileAttributes.Directory) == FileAttributes.Directory)
                {
                    if (!outputPath.EndsWith(System.IO.Path.DirectorySeparatorChar.ToString()))
                    {
                        outputPath += System.IO.Path.DirectorySeparatorChar;
                    }

                    List <string> matchingFiles = FileWalker.WalkDir(rootPath, extensionsToMatch, true);
                    foreach (var filename in matchingFiles)
                    {
                        string nwFilename = filename.Replace(rootPath, outputPath);

                        processSingleImageFile(filename, nwFilename);
                    }
                }
                else
                {
                    string nwFilename = rootPath.Replace(rootPath, outputPath);
                    processSingleImageFile(rootPath, nwFilename);
                }
            });
        }
コード例 #2
0
        private async Task processMsgFiles(string rootPath, string outputPath)
        {
            await Task.Run(async() => {
                FileAttributes attr = File.GetAttributes(rootPath);

                if ((attr & FileAttributes.Directory) == FileAttributes.Directory)
                {
                    if (!outputPath.EndsWith(System.IO.Path.DirectorySeparatorChar.ToString()))
                    {
                        outputPath += System.IO.Path.DirectorySeparatorChar;
                    }

                    List <string> matchingFiles = FileWalker.WalkDir(rootPath, Util.FileExtensions[FileType.OUTLOOK_MSG], true);
                    foreach (var filename in matchingFiles)
                    {
                        string nwFilename = filename.Replace(rootPath, outputPath);

                        processSingleMsgFile(filename, nwFilename);
                    }
                }
                else
                {
                    string nwFilename = rootPath.Replace(rootPath, outputPath);
                    processSingleMsgFile(rootPath, nwFilename);
                }
            });
        }
コード例 #3
0
        private async Task processOfficeFiles(string rootPath, string outputPath, string[] filePatterns)
        {
            // TODO: refactor so all background work is done in one thread instead of multiple async methods-->
            await Task.Run(async() =>
            {
                FileAttributes attr = File.GetAttributes(rootPath);

                if ((attr & FileAttributes.Directory) == FileAttributes.Directory)
                {
                    if (!outputPath.EndsWith(System.IO.Path.DirectorySeparatorChar.ToString()))
                    {
                        outputPath += System.IO.Path.DirectorySeparatorChar;
                    }

                    List <string> matchingFiles = FileWalker.WalkDir(rootPath, filePatterns, true);

                    foreach (var filename in matchingFiles)
                    {
                        Output.AddJournalEntry($"Found matching file: {filename}");

                        string nwFilename = filename.Replace(rootPath, outputPath) + ".pdf";
                        processSingleOfficeFile(filename, nwFilename);
                    }
                }
                else
                {
                    Output.AddJournalEntry($"Processing single file: {rootPath}");
                    string nwFilename = rootPath.Replace(rootPath, outputPath) + ".pdf";
                    processSingleOfficeFile(rootPath, nwFilename);
                }
            });
        }
コード例 #4
0
        private async Task processChangeDateTimes(string path, string filePattern, DateTime?dtCreated, DateTime?dtModified)
        {
            await Task.Run(async() =>
            {
                List <string> matchingFiles = FileWalker.WalkDir(path, pattern: filePattern);

                foreach (var filename in matchingFiles)
                {
                    if (dtCreated.HasValue)
                    {
                        File.SetCreationTime(filename, dtCreated.Value);
                    }
                    if (dtModified.HasValue)
                    {
                        File.SetLastWriteTime(filename, dtModified.Value);
                    }
                }
            });
        }