manipulating list arrays c#

HI:
I have a text file comprising two columns, separated by a '/'.
The first column reads the source name and location of a file eg c:\test\test.txt
The second column reads that files intended destination eg E:\test\test.txt
The columns number about 100 items - the second column always aligns with the first (it is derived from the first).
I am trying to write a program that copies the file referred to in the first column to the destination referred to in the second.
I have got the file to read as a list array - but am stumped as how to read each line of the list, copying from the source to the destination.
Does anybody have any experience of this? I have come across 'split' but this does not seem to do what I want - or am I missing something?!
Thanks!

Richard TeasdaleFinancial ControllerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

AndyAinscowFreelance programmer / ConsultantCommented:
           String s = "c:\test\test.txt/e:\test\test.txt";
            String[] sSplit = s.Split('/');
            String sLeft = sSplit[0];
            String sRight = sSplit[1];

sLeft is c:\test\test.txt
sRight is e:\test\test.txt
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Asim NazirCommented:
Hi,

You can read full file line-by-line.
On reading each line you will get Path1/Path2.
At this, you can use split method and this will give you source and target paths.
You can do desired operation at this point and continue this process by reading next line. Let me know if you need some code. I hope this will do.

Asim
0
Richard TeasdaleFinancial ControllerAuthor Commented:
Thanks To you both!
I am  a little stuck on reading the contents of the file to a string ; or converting the String List array to a string. Could you perhaps point me in the right direction?
Then I guess a foreach loop through each line, copying from sLeft to sRight?
Thanks!
0
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

Asim NazirCommented:
0
Asim NazirCommented:
Updated code from same url:
 
private void ProcessTxt()
        {
            string filePath = @"c:\Temp.txt";
            string line;

            if (File.Exists(filePath))
            {
                StreamReader file = null;
                try
                {
                    file = new StreamReader(filePath);
                    while ((line = file.ReadLine()) != null)
                    {
                        Console.WriteLine(line);

                        string[] lineData = line.Split("/".ToCharArray());
                        Console.Write(lineData[0]);
                        Console.Write(lineData[1]);
                    }
                }
                finally
                {
                    if (file != null)
                        file.Close();
                }
            }
        }

Open in new window

0
Richard TeasdaleFinancial ControllerAuthor Commented:
Thanks to you both!
0
Richard TeasdaleFinancial ControllerAuthor Commented:
Azim: I gave the points before I got your response., basically because AndyAinscrow provided code.
Apologies; had I seen this I would have reversed the allocation. Thank you very much for your help.
0
Asim NazirCommented:
You can request a split of points :)
But np, thanks anways.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.

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.