how to loop , read and write the folders and subfolders files
<p>I am having a problem writing the files in folders and subfolders .</p>

<p>For Example:- test is the main folder</p>

<p>1) C:\test\</p>

<p>and i want to read and write the subfolder files</p>

<p>2)C:\test\12-05-2011\12-05-2011.txt</p>

<p>3)C:\test\13-05-2011\13-05-2011.txt</p>

<p>4)C:\test\14-05-2011\14-05-2011.txt</p>

<p>My code is:</p>

<pre><code>private void button1_Click(object sender, EventArgs e)
{
    const string Path1 = @"C:\test";
    DoOnSubfolders(Path1);

    try
    {
        StreamReader reader1 = File.OpenText(Path1);
        string str = reader1.ReadToEnd();
        reader1.Close();
        reader1.Dispose();
        File.Delete(Path1);
        string[] Strarray = str.Split(new char[] { Strings.ChrW(10) });
        int abc = Strarray.Length - 2;
        int xyz = 0;
        while (xyz &lt;= abc)

}
</code></pre>

<p>I am getting an error.  The error is 
Access to the path 'C:\test' is denied.</p>

<p>Can anyone say me what i need to change in this code?</p>
