title: How to write cplex output to a text file
body: <p>I am using the IBM cplex optimizer to solve a MIP model. What I want is cplex to log not to console, but to a .txt file. I found a method that mentions this here:
  <a href="http://yalma.fime.uanl.mx/cplex11-manual/refdotnetcplex/html/ILOG.CPLEX.Cplex.SetOut.html" rel="nofollow">http://yalma.fime.uanl.mx/cplex11-manual/refdotnetcplex/html/ILOG.CPLEX.Cplex.SetOut.html</a></p>
  
  <pre><code>Cplex.SetOut(TextWriter s)
  </code></pre>
  
  <p>But when I call the method like this, the text file remains empty:</p>
  
  <pre><code>public Cplex Model= new Cplex();    
  TextWriter TWoutput = File.CreateText("RunOutput.txt"));
  //Add variables, constraints and solve the model
  Model.SetOut(TWoutput);
  </code></pre>
  
  <p>I can't find how am i supposed to use this method. I am new to c# and cplex so please explain as simple as you can :)</p>