I want to convert my code to an exe file. The bin folder has an exe file of my code , but when I run this exe file after I enter the data the window closes me without printing me the results. When I run the C# code in visual studio it ran successfully. I want my C# code to become an .exe file so people don't know what the code behind the C# file is.
Asked
Active
Viewed 2,927 times
-4
-
6Add Console.ReadLine(); at the end of the code. See https://stackoverflow.com/questions/8868338/why-is-the-console-window-closing-immediately-without-displaying-my-output – Ole EH Dufour Mar 14 '18 at 20:44
-
maybe its not the way to make the code exe file i dont know. if there is any way to make my code exe i woud like to hear about it.by the way i try to add console.readline at the end but its still closing me the window after i insert the data to my variables – Yuval Dahan Mar 14 '18 at 20:52
-
Don't understand the question, sorry... – Ole EH Dufour Mar 14 '18 at 20:55
-
never mind its work thank you !!!! – Yuval Dahan Mar 14 '18 at 20:59
-
Possible duplicate of [Why is the console window closing immediately without displaying my output?](https://stackoverflow.com/questions/8868338/why-is-the-console-window-closing-immediately-without-displaying-my-output) – Camilo Terevinto Mar 14 '18 at 21:02
-
"so people do not know what the code behind the .exe file is"??? Are you sure you are talking about C# which can be easily decompiled from exe? – Alexei Levenkov Mar 14 '18 at 23:03
1 Answers
2
When compiling your Code within Visual Studio, it will automatically generate a fully functional .exe file.
The problem you're having is that the program is done doing his job and closes itself. You have to prevent it from closing itself. You can do that by adding a simple Console.ReadLine();
at the end of your code.
For Example:
using System;
public class Program
{
public static void Main()
{
Console.WriteLine("Hello World");
Console.ReadLine();
}
}
That way the console will wait for any input before it continues to do it's work.

Vulpex
- 1,041
- 8
- 19