private static void WriteFile(string dName, String lines) { StreamWriter sw = null; try { sw = File.CreateText(dName); sw.Write(lines); } finally { if(sw != null) sw.Close(); } }