From 342af2f92770833157303ccbfbf28a2e61d5db9d Mon Sep 17 00:00:00 2001 From: Stefanos A Date: Fri, 4 Oct 2013 10:03:26 +0200 Subject: [PATCH] Fixed file not found error The debug.log would be deleted after launching an example, causing the example browser to complain that the file cannot be found. In reality, it should be deleted before launching an example - fixed. --- Source/Examples/Main.cs | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/Source/Examples/Main.cs b/Source/Examples/Main.cs index 89d03fdc..5da07c59 100644 --- a/Source/Examples/Main.cs +++ b/Source/Examples/Main.cs @@ -40,23 +40,22 @@ namespace Examples { static void LaunchExample(string type) { + try + { + if (File.Exists("debug.log")) + File.Delete("debug.log"); + if (File.Exists("trace.log")) + File.Delete("trace.log"); + } + catch (Exception e) + { + Trace.WriteLine(String.Format("Could not access debug.log", e.ToString())); + } + using (TextWriterTraceListener dbg = new TextWriterTraceListener("debug.log")) using (OpenTK.Toolkit.Init()) { Trace.Listeners.Add(dbg); - Trace.Listeners.Add(new ConsoleTraceListener()); - - try - { - if (File.Exists("debug.log")) - File.Delete("debug.log"); - if (File.Exists("trace.log")) - File.Delete("trace.log"); - } - catch (Exception e) - { - Trace.WriteLine(String.Format("Could not access debug.log", e.ToString())); - } try { @@ -75,6 +74,8 @@ namespace Examples type, e.ToString())); } + Trace.Listeners.Remove(dbg); + dbg.Flush(); dbg.Close(); } @@ -83,6 +84,8 @@ namespace Examples [STAThread] public static void Main(string[] args) { + Trace.Listeners.Add(new ConsoleTraceListener()); + if (args.Length > 0) { LaunchExample(args[0]);