filePath="s.txt" ;
private bool writeFile()
{
StreamWriter sw;
try
{
sw = File.CreateText(filePath);
sw.WriteLine("这是写入的内容");
sw.Close();
sw.Dispose();
return true;
}
catch(Exception ex)
{
return false;
}
}
private String readFile()
{
StreamReader sr = new StreamReader(filePath, System.Text.Encoding.Default);
string strRead="";
try
{
strRead = sr.ReadLine();
sr.Close();
}
catch
{
MessageBox.Show("文件读取失败");
}
return strRead;
}