2012年6月30日 星期六

ReadFile(txt)

三國志11  訊連

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))

Eramsoft        {

            string line = string.Empty;

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

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

        }

    }

    return files;

}


沒有留言:

張貼留言