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 7993243
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T13:47:40+00:00 2026-06-04T13:47:40+00:00

I have a program that loads a file, MD5 Hash’es it, and outputs the

  • 0

I have a program that loads a file, MD5 Hash’es it, and outputs the Hash to a new text file. It works well, but I have one issue. After it outputs the file successfully, the console window doesn’t close automatically, and as a result, one must close the window in order for the program to exit. How would I make it exit on its own?

code:

string hash = GetHash("1.txt");

        Console.WriteLine("Hash: {0}", hash);

        Console.ReadKey();
    }

    public static string GetHash(string pathSrc)
    {
        string pathDest = "copy_" + pathSrc;

        File.Copy(pathSrc, pathDest, true);

        String md5Result;
        StringBuilder sb = new StringBuilder();
        MD5 md5Hasher = MD5.Create();

        using (FileStream fs = File.OpenRead(pathDest))
        {
            foreach (Byte b in md5Hasher.ComputeHash(fs))
                sb.Append(b.ToString("x2").ToLower());
        }

        md5Result = sb.ToString();

        File.Delete(pathDest);

        TextWriter tw = new StreamWriter("8.txt");
        tw.WriteLine(md5Result);
        tw.Close();

        
        return md5Result;
  • 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-04T13:47:42+00:00Added an answer on June 4, 2026 at 1:47 pm

    Have you tried getting rid of the Console.ReadKey()?

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

Sidebar

Related Questions

I have a popup function in a program that works well, be re-loads the
I have a program that loads an image from a file with DirectX using
I have a program that loads a file (anywhere from 10MB to 5GB) a
I have a program that loads lines from a user file, then selects the
I have a c++ program which performs one function. It loads a large data-file
I have a short PHP program that loads an XML file (test02.xml) and then
I have an ANSI C program that dynamically loads a .so file using dlopen()
I have a program that get's input string with file path in one JTextArea
I have a Flash program that loads AS2 and AS3 SWF files dynamically with
I have a program that works with a variety of files on both the

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.