コード例 #1
0
        public async Task <string> ExtractTextAsync(string fileName)
        {
            var temp = LibUtils.RandomTempFile("txt");
            var args = ParseParameters();

            args.Add(LibUtils.QuotedStr(fileName));
            args.Add(LibUtils.QuotedStr(temp));

            var programName = LibUtils.GetProgramName(ProgramBaseName);
            var fullArgs    = LibUtils.ParseParameters(args);
            var workDir     = LibUtils.WorkDirectory;

            await CustomProcess.RunProcessAsync(programName, fullArgs, workDir);

            if (!File.Exists(temp))
            {
                return(string.Empty);
            }

            var text = await File.ReadAllTextAsync(temp);

            File.Delete(temp);

            return(text);
        }