Okay, if I am understanding this correctly, you have 2 directories (folders) and you want the file info from both directories to list in one document. So, this program will list all the files in one directory, then list all the files in the second directory all in one csv or txt file. -
Here is a very simple (basic) solution for what you are trying to do:
using System;
using System.IO;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
DirectoryInfo A = new DirectoryInfo("c:/Bank/TestFolderA");
FileInfo[] a = A.GetFiles("*.*", SearchOption.AllDirectories);
DirectoryInfo B = new DirectoryInfo("c:/Bank/TestFolderB");
FileInfo[] b = B.GetFiles("*.*", SearchOption.AllDirectories);
using (System.IO.StreamWriter file = new StreamWriter(@"c:\Bank\TestFolderC\TestResults1.csv"))
{
foreach (FileInfo x in a)
{
Console.WriteLine(@"Copying {0}, {1}, {2}, {3} ", x.DirectoryName, x.Name, x.Extension, x.Length);
file.WriteLine("{0}, {1}, {2}, {3} ", x.DirectoryName, x.Name, x.Extension, x.Length);
}
foreach (FileInfo y in b)
{
Console.WriteLine(@"Copying {0}, {1}, {2}, {3}", y.DirectoryName, y.Name, y.Extension, y.Length);
file.WriteLine("{0}, {1}, {2}, {3}", y.DirectoryName, y.Name, y.Extension, y.Length );
}
}
}
}
}
I Hope this helps with your situation and maybe help someone else in the future.