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;
}
全站熱搜