• Status: Solved
  • Priority: Low
  • Security: Public
  • Views: 78
  • Last Modified:

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.
0
Abhishek Modak
Asked:
Abhishek Modak
1 Solution
 
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
 
Abhishek ModakStudentAuthor Commented:
Thanks for your help..
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.

Join & Write a Comment

Featured Post

Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now