Eben Coarsey

Eben Coarsey

  • NA
  • 2
  • 15k

Beginner Problem with StreamWriter

Oct 25 2010 1:26 PM
I am using StreamWriter to debug a stock trading program and my code creates the file, but will not write to it.  I am sure I am missing something simple.  I know the method is being used because the D() command you see writes to a debug window.  I am not sure what I am missing but the file is created, but always empty.

public class SterlingDebug : ResponseTemplate
    {   
StreamWriter writer = new StreamWriter(@"C:\Documents and Settings\ecoarsey\SterlingIssue10222010.txt");     
int i = 0; public override void GotTick(Tick tick) {
i++; if (i < 11) { D(tick.ToString()); writer.WriteLine("Tick #: {0}",i); }
}
}

Answers (2)