Running a loop to select multiple files for encryption and decryption

I have developed an application that selects one file at a time for encryption and decryption purpose. Can someone suggest me how to run a loop so that I am able to select multiple files at a time for encryption and decryption purpose.
Abhishek ModakStudentAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

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

it_saigeDeveloperCommented:
No need to run a loop, depending upon the version of .NET use are using, simply use GetFiles or EnumerateFiles and provide a filter which matches the files you are looking for; e.g. -
using System;
using System.IO;

namespace EE_Q29088412
{
    class Program
    {
        static void Main(string[] args)
        {
            var files = new DirectoryInfo(@"c:\_admin").GetFiles("*.txt", SearchOption.AllDirectories);
            foreach (var file in files)
            {
                Console.WriteLine(file.FullName);
            }
            Console.ReadLine();
        }
    }
}

Open in new window

using System;
using System.IO;

namespace EE_Q29088412
{
    class Program
    {
        static void Main(string[] args)
        {
            var files = new DirectoryInfo(@"c:\_admin").EnumerateFiles("*.txt", SearchOption.AllDirectories);
            foreach (var file in files)
            {
                Console.WriteLine(file.FullName);
            }
            Console.ReadLine();
        }
    }
}

Open in new window

Each of which produce the same output.

-saige-
1

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
Abhishek ModakStudentAuthor Commented:
Thanks for your help..
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
Encryption

From novice to tech pro — start learning today.