出现这样的错误是因为打开了文件没有关闭,
修改一下
StreamWriter sw = null;
try
{
sw = new StreamWriter(file,false,System.Text.Encoding.Default);
sw.WriteLine("ok!");
sw.Flush();
}
finally
{
sw.Close();
}
修改一下
StreamWriter sw = null;
try
{
sw = new StreamWriter(file,false,System.Text.Encoding.Default);
sw.WriteLine("ok!");
sw.Flush();
}
finally
{
sw.Close();
}
{
File.Create(file);
}
这段不要啦,sw会自动生成的