concatanate arrays c#

Hi:
I have a form that generates 2 text files.
Each comprises a list of directories at a given location; displayed in a list box and output to text file.
Ideally I would like ONE text file, with EACH list in it. Both directories will always be the same so I can read the file and the entries will line up.
So...I have tried creating a single file and adding both arrays - and failed
I have tried creating a single array, populated with both lists - and failed.
Could anybody point me (a novice) in the right direction, please?
Thanks!
private void button5_Click(object sender, EventArgs e)
        {
            //list the source
            string[] sfolders = System.IO.Directory.GetDirectories(@"R:\data\lister\", "*", System.IO.SearchOption.AllDirectories);
            foreach (string s in sfolders)
            {

                System.Diagnostics.Debug.Write(s);
                listBox2.DataSource = sfolders;


            }
            //list the destination
            string[] dfolders = System.IO.Directory.GetDirectories(@"C:\lister\", "*", System.IO.SearchOption.AllDirectories);
            foreach (string d in dfolders)
            {

                System.Diagnostics.Debug.Write(d);
                listBox3.DataSource = dfolders;


            }
            
            System.IO.File.WriteAllLines(@"C:\\lister\\DFolders.txt", dfolders);
            System.IO.File.WriteAllLines(@"C:\\lister\\SFolders.txt",sfolders);
        }

Open in new window

Richard TeasdaleFinancial ControllerAsked:
Who is Participating?
 
Guy Hengel [angelIII / a3]Connect With a Mentor Billing EngineerCommented:
you might want to create an arrayList, and add both arrays into it, and set the datasource to that arraylist
http://www.java2s.com/Code/CSharp/Collections-Data-Structure/AddarraytoArrayList.htm
0
 
Richard TeasdaleFinancial ControllerAuthor Commented:
Thanks!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.