I have the following code that should go td on each of them through the org list, call the toString method for each of them and print the result both on the console and on a file called Debug1.tab.
try { StreamWriter print = File.CreateText("Debug1.tab"); Console.WriteLine(LinkedInClass.isThrottled); int p = 1; foreach (Org org in orgList) { try { if (org.numContacts > 0) { Console.WriteLine(org.ToString()); print.WriteLine(org.ToString()); } } catch (Exception) { Console.WriteLine(e.StackTrace); Console.WriteLine(e.Message); Console.ReadKey();} } print.Close(); Console.WriteLine("There were " + orgList.Count + " organizations in the list." + LinkedInClass.numWithContacts + " of which I found contacts for. Throttling was "+(LinkedInClass.isThrottled?"":"not ")+"encountered."); break; } catch (Exception e) { Console.WriteLine(e.StackTrace); Console.WriteLine(e.Message); Console.ReadKey(); }
It works fine in Visual Studio, but when I publish it, the program does not create the file or write it. It still writes to the console, catch statements are not executed, and immediately after closing StreamWriter, it correctly prints to the console.
source share