C# Command Line Compiler

Hello all,

I've started playing around with C# and have had a bit of a look at C# visual studio express 2008, but I find my laptop doesn't run it very well as it is old and tired. So I thought I might try compiling with cmd.
I eventually managed to get it to recognise csc, but now when I type for example "csc HelloApp.cs" it displays errors cs2001 and cs2008, I have added the path to the folder containing my .cs files to the path variable under system variables in my computer properties, but it cant seem to find it.

 What am I doing wrong? Any help or suggestions much appreciated
LVL 22
Kelvin SparksAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

cs2001 means: your cs-file can not be found by the compiler (csc.exe)
for cs2008 you might find help here:
Kelvin SparksAuthor Commented:
Sorted it out now, thanks.
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

here is running sample
complied to an exe.

Save the attached code to main.cs in folder

go to the command line (cmd)
navigate to the folder
(cd C:\CSC_compile)

and type:
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\csc.exe /target:exe  main.cs

This will generate a main.exe

using System;

namespace TEST
    class Program
        static void Main(string[] args)
            Console.WriteLine("Hello World");

Open in new window

you are welcome :)
Altin BardhiSoftware EngineerCommented:
Visual studio should have its own command line. Anyway if you have added the full path under 'environment variables' -> path this should work.

Also try to change the cmd path by typing: cd>(change directory) C:/path to the folder/

First though check if the 'cmd line' of your VS is working properly as you could have some instalation problem.
All Courses

From novice to tech pro — start learning today.