Writing to the wrong txt file c#
<p>I'm trying to write a code to write two text files.</p>

<p>I created two subroutines for that because they are used in diferent ocasions. But, when I run the code, insted of writing in two text files, all the info that I need to write is beeing writen in only on one file, not two.</p>

<p>Could you guys help me figure out what I did wrong?</p>

<p>I think I'm handling the Path the wrong way, but i can't figure out the proper use</p>

<pre><code>private void COBEQ2016_Click(object sender, EventArgs e)
{
    ///////////////////////////////////////////////////////////////////////////////////////////////////////
    Global.Filename = String.Format("{0:yyyy-MM-dd_hh-mm-ss-tt}__{1}", DateTime.Now, "cobeqswarm_ocresol_la_bin.txt");
    string path = Path.Combine(Directory.GetCurrentDirectory(), Global.Filename);
    File.Create(path).Close();


    ///////////////////////////////////////////////////////////////////////////////////////////////////////
    Global.Filename2 = String.Format("{0:yyyy-MM-dd_hh-mm-ss-tt}__{1}", DateTime.Now, "cobeqswarm_JAC_ocresol_la_bin.txt");
    string path2 = Path.Combine(Directory.GetCurrentDirectory(), Global.Filename2);
    File.Create(path2).Close();


    //A lot of math//
double[] minX = new double[] { -3000, -400 }; 
textfile(minX, 100.0);
textfile2(minX);    


}
 public void textfile(double[] param1, double param2)
 {
     ///////////////////////////////////////////////////////////////////////////////////////////
     string[] tes2 = new string[9];
     string path = Path.Combine(Directory.GetCurrentDirectory(),Global.Filename);

     if (!File.Exists(path))
     {
         File.Create(path).Close();
         TextWriter tw = new StreamWriter(path,true);
         tw.WriteLine("");
         int i=0;
         while (i&lt;param1.GetLength(0))
         {
             tw.Write(param1[i].ToString("0.000000000000000000"));
             tw.Write(" ");
             i++;
         }
         tw.Write(param2.ToString("0.000000000000000000"));
         tw.Write(" ");

         tw.Close();
     }
     else if (File.Exists(path))
     {
         TextWriter tw = new StreamWriter(path, true);
         tw.WriteLine("");
         int i = 0;
         while (i &lt; param1.GetLength(0))
         {
             tw.Write(param1[i].ToString("0.000000000000000000"));
             tw.Write(" ");
             i++;
         }
         tw.Write(param2.ToString("0.000000000000000000"));
         tw.Write(" ");

         tw.Close();
     }
     ///////////////////////////////////////////////////////////////////////////
 }//textfile
 public void textfile2(double[] param0)
 {
     string[] tes2 = new string[9];
     string path2 = Path.Combine(Directory.GetCurrentDirectory(), Global.Filename2);

     if (!File.Exists(path2))
     {
         File.Create(path2).Close();
         TextWriter tw = new StreamWriter(path2, true);
         tw.WriteLine("");
         int i = 0;
         while (i &lt; param0.GetLength(0))
         {
             tw.Write(param0[i].ToString("0.000000000000000000"));
             tw.Write(" ");
             i++;
         }
       //  tw.Write(param2.ToString("0.000000000000000000"));
         tw.Write(" ");

         tw.Close();
     }
     else if (File.Exists(path2))
     {
         TextWriter tw = new StreamWriter(path2, true);
         tw.WriteLine("");
         int i = 0;
         while (i &lt; param0.GetLength(0))
         {
             tw.Write(param0[i].ToString("0.000000000000000000"));
             tw.Write(" ");
             i++;
         }

         tw.Write(" ");

         tw.Close();
     }
     ///////////////////////////////////////////////////////////////////////////
     ///////////////////////////////////////////////////////////////////////////
 }//textfile2
</code></pre>