//讀取txt文件的內容
public static string GettfCount(string strfile)
{
string strout;
strout = "";
if (!File.Exists(System.Web.HttpContext.Current.Server.MapPath(strfile)))
{
strout = "文件出錯!聯繫管理員";
}
else
{
StreamReader sr = new StreamReader(System.Web.HttpContext.Current.Server.MapPath(strfile), System.Text.Encoding.Default);
String input = sr.ReadToEnd();
sr.Close();
strout = input;
}
return strout;
}
//重寫
public static void addTFCount(string strfile,string value)
{
string path = System.Web.HttpContext.Current.Server.MapPath(strfile);
FileStream fs = new FileStream (path,FileMode.OpenOrCreate,FileAccess.Write);
StreamWriter m_streamWriter = new StreamWriter(fs, System.Text.Encoding.GetEncoding("utf-8"));
m_streamWriter.Write(value);
m_streamWriter.Flush();
m_streamWriter.Close();
}