C#文字檔案內容搜尋(C# search content of the text file)

C#文字檔案內容搜尋(C# search content of the text file)

C#文字檔案內容搜尋(C# search content of the text file)


 

資料來源:

http://jashliao.pixnet.net/blog/post/206148181

http://jashliao.pixnet.net/blog/post/206071093

 

 

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.IO;

 

namespace CS_Console_File_Search_Content

{

    class Program

    {

        static
void Pause()

        {

            Console.Write(“Press any key to continue . . . “);

            Console.ReadKey(true);

        }

        static
void Main(string[]
args)

        {

            Boolean
blnSearch=false;

            if
(System.IO.File.Exists(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + @”\v7_config.csv”))

            {

                //3

                StreamReader
sr = new StreamReader(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + @”\v7_config.csv”);

                while
(!sr.EndOfStream)//
LC¡MaLu@aA?LiE±A

                {

                    string
line = sr.ReadLine();//
aLuarLi line UA

                    if(line.Contains(“server_ver”))

                    {

                        Console.WriteLine(line);

                        blnSearch=true;

                        break;

                    }

 

                }

                sr.Close();// o?ey

                if(!blnSearch)

                {

                    Console.WriteLine(LS3±aLiUoMeA”);

                }

            }

            else

            {

                Console.WriteLine(LS3E¡Ñ”);

            }

 

            Pause();

        }

    }

}

 

 

 


 


發表迴響

你的電子郵件位址並不會被公開。 必要欄位標記為 *