• 大小: 44KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-06-03
  • 语言: 其他
  • 标签: C#  

资源简介

简单本地检索系统,用vs2008实现的。

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Text.Regularexpressions;

namespace 本地检索系统
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        ListBox li_box = new ListBox();
        ListBox li_keyword = new ListBox();

        private void btn_From_file_Click(object sender EventArgs e)
        {
            FolderBrowserDialog Fdialog = new FolderBrowserDialog();
            if (Fdialog.ShowDialog() == DialogResult.Cancel)
                return;

            txt_Firl.Text = Fdialog.SelectedPath;

        }

        private void btn_begin_Click(object sender EventArgs e)
        {
            try
            {
                if (txt_Firl.Text.Length == 0)
                {
                    return;
                }


                //*********************************
                listBox1.Items.Clear();
                richTextBox1.Text = ““;

                //**********ComboBox的处理***********************
                string com_text = ““;
                switch (comboBox1.SelectedIndex)
                {
                    case 0: com_text = “*.txt“;
                        break;
                    case 1: com_text = “*.cs“;
                        break;
                    default: com_text = “*.txt“;
                        break;
                }

                DirectoryInfo dit = new DirectoryInfo(txt_Firl.Text.Trim());
                FileInfo[] many = dit.GetFiles(com_text SearchOption.AllDirectories);

                foreach (FileInfo eveyone in many)
                {
                    this.li_box.Items.Add(eveyone.FullName);
                }
                //**********************关键词的处理************************

                //slipt_keyword();

                //********************没有关键词的情况**********************
                if (txt_KeyWord.Text.Length > 0)
                {
                    search_keyword();
                }
                else
                {
                    listBox1.Items.AddRange(li_box.Items);
                }

                //释放
                li_box.Items.Clear();
            }
            catch { }



        }

        private void search_keyword()
        {
            for (int i = 0; i < li_box.Items.Count; i++)
            {
                StreamReader thereader = new StreamReader(li_box.Items[i].ToString() Encoding.Default);
                string file_text = thereader.ReadToEnd();





                if (file_text.IndexOf(txt_KeyWord.Text.Trim()) >= 0)
                {
                    try
                    {
                        file_text = file_text.Replace(“\r\n““ “);
                        int Pos

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件      12800  2011-06-29 19:21  本地检索系统\本地检索系统\bin\Debug\本地检索系统.exe

     文件      28160  2011-06-29 19:21  本地检索系统\本地检索系统\bin\Debug\本地检索系统.pdb

     文件      14328  2011-06-29 19:22  本地检索系统\本地检索系统\bin\Debug\本地检索系统.vshost.exe

     文件        490  2007-07-21 01:33  本地检索系统\本地检索系统\bin\Debug\本地检索系统.vshost.exe.manifest

     文件       5868  2011-06-29 19:21  本地检索系统\本地检索系统\Form1.cs

     文件       7240  2011-06-29 19:21  本地检索系统\本地检索系统\Form1.Designer.cs

     文件       5814  2011-06-29 19:21  本地检索系统\本地检索系统\Form1.resx

     文件        697  2011-06-29 22:33  本地检索系统\本地检索系统\obj\Debug\本地检索系统.csproj.FileListAbsolute.txt

     文件        847  2011-06-29 19:21  本地检索系统\本地检索系统\obj\Debug\本地检索系统.csproj.GenerateResource.Cache

     文件      12800  2011-06-29 19:21  本地检索系统\本地检索系统\obj\Debug\本地检索系统.exe

     文件        180  2011-06-29 19:21  本地检索系统\本地检索系统\obj\Debug\本地检索系统.Form1.resources

     文件      28160  2011-06-29 19:21  本地检索系统\本地检索系统\obj\Debug\本地检索系统.pdb

     文件        180  2011-06-29 16:05  本地检索系统\本地检索系统\obj\Debug\本地检索系统.Properties.Resources.resources

     文件        499  2011-06-29 12:23  本地检索系统\本地检索系统\Program.cs

     文件       1392  2011-06-29 12:23  本地检索系统\本地检索系统\Properties\AssemblyInfo.cs

     文件       2886  2011-06-29 12:23  本地检索系统\本地检索系统\Properties\Resources.Designer.cs

     文件       5612  2011-06-29 12:23  本地检索系统\本地检索系统\Properties\Resources.resx

     文件       1103  2011-06-29 12:23  本地检索系统\本地检索系统\Properties\Settings.Designer.cs

     文件        249  2011-06-29 12:23  本地检索系统\本地检索系统\Properties\Settings.settings

     文件       3782  2011-06-29 12:49  本地检索系统\本地检索系统\本地检索系统.csproj

     文件        944  2011-06-29 12:24  本地检索系统\本地检索系统.sln

    ..A..H.     13312  2011-06-29 22:34  本地检索系统\本地检索系统.suo

     目录          0  2011-06-29 12:46  本地检索系统\本地检索系统\obj\Debug\Refactor

     目录          0  2011-06-29 12:23  本地检索系统\本地检索系统\obj\Debug\TempPE

     目录          0  2011-06-29 16:05  本地检索系统\本地检索系统\bin\Debug

     目录          0  2011-06-29 19:21  本地检索系统\本地检索系统\obj\Debug

     目录          0  2011-06-29 12:23  本地检索系统\本地检索系统\bin

     目录          0  2011-06-29 12:23  本地检索系统\本地检索系统\obj

     目录          0  2011-06-29 12:23  本地检索系统\本地检索系统\Properties

     目录          0  2011-06-29 19:21  本地检索系统\本地检索系统

............此处省略4个文件信息

评论

共有 条评论