What I'm trying to achieve is a self-compiled c# file without toxic output.I'm trying to achieve this with Console.MoveBufferArea method but looks does not work.
Eg. - save the code below with .bat
extension :
// 2>nul||@goto :batch
/*
:batch
@echo off
setlocal
:: find csc.exe
set "frm=%SystemRoot%\Microsoft.NET\Framework\"
for /f "tokens=* delims=" %%v in ('dir /b /a:d /o:-n "%SystemRoot%\Microsoft.NET\Framework\v*"') do (
set netver=%%v
goto :break_loop
)
:break_loop
set csc=%frm%%netver%\csc.exe
:: csc.exe found
%csc% /nologo /out:"%~n0.exe" "%~dpsfnx0"
%~n0.exe
endlocal
exit /b 0
*/
public class Hello
{
public static void Main() {
ClearC();
System.Console.WriteLine("Hello, C# World!");
}
private static void ClearC() {
System.Console.MoveBufferArea(
0,0,
System.Console.BufferWidth,System.Console.BufferHeight-1,
0,0
);
}
}
the output will be:
C:\>// 2>nul ||
Hello, C# World!
What want is to rid of the // 2>nul ||
.Is it possible? Is there something wrong in my logic (the ClearC
method)?Do I need PInvoke?