Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

C#

Can't run program in console on Windows

Hello,

I am watching the "Start coding" course of c#.

The author says that if we want to run Program.exe in the console on windows, we need to type 'it' in the console. I assume he means "Program.exe" in the console.

But after I made the .exe file and typed ls in the console to check if it got through (and it lists the Program.exe), I can't run Program.exe by typing this in the console.

I get the error: Program.exe: command not found What am I doing wrong?

Thanks in advance.

Afrid Mondal
Afrid Mondal
6,255 Points

Make sure you changed your directory when you running the command. Means, where does your program is actually is. Change your directory to that position then run.

So I work in the workspace of Treehouse.

I am in the folder c# basics - Receiving input. I have the code showing of Program.cs. In the folder below Program.cs there is a Program.exe.

How do I tell the console to run Program.exe in the same folder?

1 Answer

Steven Parker
Steven Parker
231,248 Points

In the video, the teacher says "On Windows you could run this program by typing it here a the command prompt." Note that he does not say "in the console".

Since you mentioned the console, and also that you "typed ls" (which is a console command, but not a windows command), I'm guessing you are using the workspace.

If that's the case, you want to follow the advice given at 5:27 in the video, which is "To run a program in WorkSpaces, just type: mono Program.exe." The teacher does it himself in the video as he says it.

Try that and see if that works for you:

:point_right: mono Program.exe

Thanks! I was confused by that line indeed.