title: Why does my StreamWriter not write to file?
body: <p>I'm making a log for my program using a StreamWriter to write to a file.  I have some code that looks like it works, but its only doing part of what it should.  </p>
  
  <p>I made a simple class called Log (code below).</p>
  
  <pre><code>public class Log
  {
  string path;
  StreamWriter fs;
  public Log(string fullPathToLogFile)
  {
      path = fullPathToLogFile;
      fs = new StreamWriter(path);
      writeLog("Starting log");
  }
  public void writeLog(string s)
  {
      fs.WriteLine(DateTime.Now.ToString("dd-MM-yyyy  H:mm:ss         ") + s);
  }
  public void closeLog()
  {
      writeLog("Closing log");
      fs.WriteLine(); //add a blank line at the end
      fs.Close();
  
  }
  }
  </code></pre>
  
  <p>I made a simple test program that works perfectly.  It executes these three lines:</p>
  
  <pre><code>Log l = new Log(@"C:\Users\SADunkerton\Desktop\l.txt");
  l.writeLog("testing log");
  l.closeLog();
  </code></pre>
  
  <p>But in my much larger program, where I actually want to use the Log class, all I get is an empty file --no text inside.  Its code looks like this:</p>
  
  <pre><code>Log log = new Log(folderPDFs + @"\Log.txt"); //folderPDFs is a parameter of this method--it is a string that is a complete path to a destination folder.
  log.writeLog("Beginning conversions");
  //do some stuff, including write to the log
  log.writeLog("Finished converting.  Success = " + success);
  </code></pre>
  
  <p>Can anyone tell me why the program version of this code isn't working?</p>