Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9249773
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T10:16:57+00:00 2026-06-18T10:16:57+00:00

As you can see by the commented code below, I’m trying to display the

  • 0

As you can see by the commented code below, I’m trying to display the name and checksum for each file in a folder inside a message box. The problem is that this pops up a separate message box for each file, rather than displaying them all in one window. I realize that I need to move the MessageBox.Show() line outside of the foreach loop, but then it only displays the last file and not all of them.

What would be the code to display all the files in one message box?

// for each file in selected folder, print out its name and MD5 checksum value
   foreach (string file in Directory.GetFiles(folderBrowserDialog1.SelectedPath))
   {
       using (var md5 = MD5.Create())
       {
           using (var stream = File.OpenRead(file))
           {
               checksum = BitConverter.ToString(md5.ComputeHash(stream)).Replace("-", "").ToLower();
               MessageBox.Show(file + ": " + checksum);
           }
       }
   }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T10:16:59+00:00Added an answer on June 18, 2026 at 10:16 am

    Use a StringBuilder and then append the file/checksum to the stringbuilder object during each iteration, then call MessageBox.Show() on the stringbuilder object, for example:

    StringBuilder s = new StringBuilder();
    foreach (string file in Directory.GetFiles(folderBrowserDialog1.SelectedPath))
    {
        using (var md5 = MD5.Create())
        {
            using (var stream = File.OpenRead(file))
            {
                checksum = BitConverter.ToString(md5.ComputeHash(stream)).Replace("-", "").ToLower();
                s.AppendLine(file + ": " + checksum);
            }
        }
    }
    MessageBox.Show(s.ToString());
    

    Or use:

    s.AppendFormat("{0}: {1}", file, checksum).AppendLine();
    

    Inside the loop to avoid the overhead of creating a new string for each iteration of the loop *credit goes to Destrictor*

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I can see the Graphical Layout of the XML file within the /res/layout folder,
In the code below and demo here http://jsfiddle.net/jasondavis/vp2YN/3/ you can see I need to
(the example code below is self-contained and runnable, you can try it, it won't
Can I put comments ( commented out code or notes that don't affect the
Possible Duplicate: Modifying a const through a non-const pointer lets' see the code below
I have been trying, searching, trying, researching all night to see how I can
On the developer page (http://developers.facebook.com/docs/reference/plugins/comments/) I can see that the facebook comment Social plugin
I can see it looks like an alias for an unsigned int pointer, right?
I can see where svn:keywords like Id, LastChangedDate and Author are used and replaced
I can see how to change the fonts and colors in the IDE. Is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.