Fix CA2202 code analysis warning in the Windows wizard

This commit is contained in:
Gunnar Beutner 2014-11-13 20:18:41 +01:00
parent 979b99ea6f
commit 98d81ffc85
1 changed files with 22 additions and 16 deletions

View File

@ -83,10 +83,16 @@ namespace Icinga
private void EnableFeature(string feature) private void EnableFeature(string feature)
{ {
using (FileStream fp = File.Open(Icinga2InstallDir + String.Format("\\etc\\icinga2\\features-enabled\\{0}.conf", feature), FileMode.Create)) { FileStream fp = null;
try {
fp = File.Open(Icinga2InstallDir + String.Format("\\etc\\icinga2\\features-enabled\\{0}.conf", feature), FileMode.Create);
using (StreamWriter sw = new StreamWriter(fp, Encoding.ASCII)) { using (StreamWriter sw = new StreamWriter(fp, Encoding.ASCII)) {
fp = null;
sw.Write(String.Format("include \"../features-available/{0}.conf\"\n", feature)); sw.Write(String.Format("include \"../features-available/{0}.conf\"\n", feature));
} }
} finally {
if (fp != null)
fp.Dispose();
} }
} }