我正在使用文件流和流写器在文件上写一个小文本,它给我CA2202警告
public void WritePIDToFile()
{
FileStream fh = null;
try
{
fh = new FileStream(HIMSHelper.ApplicationDirectory + "PID", FileMode.Open, FileAccess.ReadWrite, FileShare.Read);
using (var sr = new StreamWriter(fh))
{
sr.Write(PID);
}
}
finally
{
if (fh != null)
{
fh.Dispose();//I got CA2202 here
}
}
}
我已在此处尝试解决方案CA2202: Do not dispose objects multiple times
你能给我什么建议吗?请。由于