How to read and update multiple files
<p>I have 10 txt files in Debug\Tests\Text\ (10 txt files). I need to write a program to open all 10 files and updated every single file. I'm not sure how to do it. Now, I'm actually reading the folder and getting the file name and storing the file name in an array. Below is my code: </p>

<pre><code>private void getFilesName()
{
    string[] fileArray = Directory.GetFiles(@"Tests\Text");

    //looping through the folder and get the fileNames
    for (int i = 0; i&lt;fileArray.Length; i++)
    {
        MessageBox.Show(fileArray[i]); // I'm doing this is to double check i manage to get the file name.
    }

}
</code></pre>

<p>After doing this, it do read all the text file name, but the challenge now is for me to access the filename and updating every file in it. I have also created another method just for updating the values in the txt files, below is the code:</p>

<pre><code>private bool modifySQLFile()
{
    string destFileName = @"Tests\Text\" // I need the fileName? 
    string[] fileTexts = File.ReadAllLines(destFileName);
    int counter = 0;

    //Processing the File
    foreach(string line in fileTexts)
    {
        //only read those non-comments line
        if(line.StartsWith("--") == false)
        {
            //Start to replace instances of Access ID
            if(line.Contains(Variable) == true)
            {
                fileTexts[counter] = fileTexts[counter].Replace(Variable, textBox2.Text);
            }
        }
        counter++;
    }

    //check if file exists in the backup folder
    if(File.Exists("Tests\\Text\\file name "+ textBox1.Text +".sql") == true)
    {
        MessageBox.Show("This file already exist in the backup folder");
        return false;
    }

    else
    {
        //update the file
        File.WriteAllLines(destFileName, fileTexts);
        File.Move(destFileName, "Tests\\Text\\file name"+ textBox1.Text +".sql");
        MessageBox.Show("Completed");
        return true;
    }
}
</code></pre>