write the list of files in a folder to afile
<p>I wrote a code to read all the files in a folder, then write them to a file. All the code complies and runs okay, but <strong>the filenames of the files are not displayed in the new file.</strong></p>

<p><strong>Code:</strong></p>

<pre><code>private void Form1_Load(object sender, EventArgs e)
{
    DialogResult result = folderBrowserDialog1.ShowDialog(); // Show the dialog.
    // create a list to insert the data into
    //put all the files in the root directory into array
    string[] array1 = Directory.GetFiles(@"C:\Users\a3708906\Documents\Filereader m 15062012", "*.csv");

    // Display all files.
    TextWriter tw1 = new StreamWriter("C:/Users/a3708906/Documents/Filereader m 15062012/Filereader m 15062012/listoffiles.txt");
    List&lt;string&gt; filenames = new List&lt;string&gt;();
    tw1.WriteLine("--- Files: ---");
    foreach (string name in array1)
    {
            tw1.WriteLine(name);
    }
    tw1.Close();
}
</code></pre>

<p>I would be grateful for your assistance. </p>
