public string GetString(string FileName)
{
string tempstr;
try{
StreamReader sr = new StreamReader(FileName);
tempstr= sr.ReadLine();
sr.Close();
return tempstr;
}
catch(Exception ex)
{
return ex.ToString();
}
}
{
string tempstr;
try{
StreamReader sr = new StreamReader(FileName);
tempstr= sr.ReadLine();
sr.Close();
return tempstr;
}
catch(Exception ex)
{
return ex.ToString();
}
}
你是想把bool值赋给它还是从filename中读出的信息赋给它?
前者用.ToString()方法;
后者可以参考 bitsbird(一瓢.net)。
huhu~~~~
public string LoadFromFile(string FileName)
{
try
{
string tempstr; StreamReader sr = new StreamReader(FileName);
tempstr= sr.ReadLine();
sr.Close();
return tempstr;
}
catch
{
return null;
}
}
public string LoadFromFile(string FileName)
{
try
{
string tempstr; StreamReader sr = new StreamReader(FileName);
tempstr= sr.ReadLine();
sr.Close();
return tempstr;
}
catch
{
return null;
}
}
健壮性不上一个好。