C#多线程处理文件的简单例子

这个C#程序使用多线程从文本文件中提取特定信息,如申请人、代码、关键词等,并将结果写入新文件。程序首先读取指定文件夹中的所有.txt文件,然后创建多个线程进行并行处理,每个线程处理文件的一部分。提取到的信息包括申请代码数量、代码详情、关键词等。
摘要由CSDN通过智能技术生成
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;


namespace vs2012csharp
{ 
    class Program
    {
        ArrayList fileList;
        static int ThreadNum = 3;

        static string ProposalExtractLessInfo(string inputfile, string outputfile1, string outputfile2)
        {
            string paperText = File.ReadAllText(inputfile, Encoding.Default);

            string strRegexProposer = @"申\s+请\s+人:(?<Proposer>\w+)\s+[^\r\n]+[\r\n]+依托单位:(?<Proposer_Org>\w+)";
            Regex regProposer = new Regex(strRegexProposer, RegexOptions.Singleline);
            Match matchProposer = regProposer.Match(paperText);


            string strRegexExpCode = @"申请代码\s+((?:[A-Z\d]+:\w+\s+)+)";
            Regex regExpCode = new Regex(strRegexExpCode, RegexOptions.Singleline);
            Match matchCode = regExpCode.Match(paperText);
            //Console.WriteLine(matchCode.Groups[1].Value);
            //Console.WriteLine(matchCode.Groups[2].Value);
            string[] codeDesArr = matchCode.Groups[1].Value.Split('
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值