//路径、文件名、写入内容
void CreateOrOPenFile(string path, string name, string info)
{
StreamWriter sw;
FileInfo fi = new FileInfo(path + "//" + name);
//直接重新写入,如果要在原文件后面追加内容,应用fi.AppendText()
sw = fi.CreateText();
sw.WriteLine(info);
sw.Close();
sw.Dispose();
}
void LoadFileAndIntialSpeed(string sPath, string sName)
{
StreamReader sr = null;
sr = File.OpenText(sPath + "//" + sName);
string t_sLine;
if ((t_sLine = sr.ReadLine()) != null)
{
//do some thing with t_sLine
}
else
{
//print("Null!");
}
sr.Close();
sr.Dispose();
}
网友评论