How do you clear screen or execute an OS level task

  • Thread starter Thread starter Sam
  • Start date Start date
S

Sam

Sorry one of those "C" type transistion questions which I
could find no answer for in existing C# text books.

In C, I used to use the system function call to execute
programs synchronously.

To clear the screen, for console based programs, I used
to include the following statement in my program.

system("cls"); // For DOS/windows based programs
system("clear"); // for UNIX based programs

So does anyone know :

1. The .NET library equivalent to the old system function
call.

2. How to clear the screen for console based programs.

Thanks
 
Sam,

If you want to do this, then you will have to create a DLL which exports
a function which will pass the command you want to the system call. I
believe that system was part of the C runtime, which is a library and can't
be accessed through .NET directly.

However, you should probably use one of the console functions in
kernel32.dll, as they would be easier to import into your program through
the P/Invoke layer.

Hope this helps.
 
Back
Top