can someone show me how to use C# to read each file line by line and write it to a new file in the folder

i have 3 files called "org_1", "org_2", "org_3" in the folder called Folder_1, can someone show me how to use C# to read each file line by line and write it to a new file in the folder called "Folder_2" and name the files "copy_1", "copy_2" and "copy3".
musclejackAsked:
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.

amit_gCommented:
You can simply use use copy...

using System;
using System.IO;

File.Copy(@"Folder_1\ord_1", @"Folder_2\copy_1");

but if you want to open read and write ...

using System;
using System.IO;

        try
        {
            StreamReader sr = new StreamReader(@"Folder_1\ord_1")
            StreamWriter sw = new StreamReader(@"Folder_2\copy_1")

            String line;

            while ((line = sr.ReadLine()) != null)
            {
                sw.WriteLine(line);
            }
        }
        catch (Exception e)
        {
            // Let the user know what went wrong.
        }
musclejackAuthor Commented:
actually, in the files, the 2nd line contain a date, i want to replace to todays date. thx
amit_gCommented:
Then use the loop with read and write.
musclejackAuthor Commented:
example please
amit_gCommented:
I have already posted it after the "but if you want to open read and write ...". Do you need help in replacing also ...

Change

sw.WriteLine(line);

to

sw.WriteLine(line.Replace("OldDate", "NewDate"));

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
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.