日期:2014-05-17  浏览次数:21003 次

c#读取大容量txt文件怎么才能不卡
c#读取大容量txt文件怎么才能不卡还请高手指教,在线等,谢谢了,

------解决方案--------------------
多线程 

//例子
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Threading;

namespace MultiThread
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        private void button1_Click(object sender, EventArgs e)
        {
            using (FolderBrowserDialog fbd = new FolderBrowserDialog())
            {
                fbd.Description = "选择要多线程读取文件的路径";
                fbd.ShowNewFolderButton = false;
                if (fbd.ShowDialog(this) == DialogResult.OK)
                {
                    DirectoryInfo di = new DirectoryInfo(fbd.SelectedPath);
                    foreach (FileInfo fi in di.GetFiles("*.txt"))
                    {
                        Thread t = new Thread(this.InvokeThread);
                        t.Start(fi.FullName);
                    }
                }