在这篇文章的一些帮助下,
https://support.roguewave.com/documentation/klocwork/en/10-x/cs.nps/
即使在明确设置安全性之后,我仍然会收到 klocwork 错误。解决它的任何解决方案。
下面的代码行给出错误,
streamWriter.WriteLine("Hello");
这是完整的代码,
using (var stream = new FileStream(@"C:\\sample.txt", FileMode.Create))
{
var security = new System.Security.AccessControl.FileSecurity();
security.AddAccessRule(new FileSystemAccessRule(@"domain\user", FileSystemRights.Modify, AccessControlType.Allow));
stream.SetAccessControl(security);
using (var streamWriter = new StreamWriter(stream))
{
streamWriter.WriteLine("Hello");
}
}