public string ReadFile()

{

    string files = string.Empty;

    string filePath = System.Environment.CurrentDirectory + "\\test.txt";//webform: Server.MapPath("~")+"\\folder\\test.txt";

    if (System.IO.File.Exists(filePath))

    {

        using (System.IO.StreamReader sr = new System.IO.StreamReader(filePath))

        {

            string line = string.Empty;

            while (!string.IsNullOrEmpty(line = sr.ReadLine()))

                files += line + ", ";//抓出每一行以逗點隔開

        }

    }

    return files;

}

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 Big Bear 的頭像
    Big Bear

    Programs Knowledge

    Big Bear 發表在 痞客邦 留言(0) 人氣()