Run Dos console program without showing it's window to textbox
// 1. creating process
CompressProcess = new Process();
// 2. configuring redirection
CompressProcess.StartInfo.UseShellExecute = false;
CompressProcess.StartInfo.RedirectStandardOutput = true;
CompressProcess.StartInfo.RedirectStandardError = true;
CompressProcess.StartInfo.CreateNoWindow = true;
CompressProcess.StartInfo.FileName = «7z.exe»;
CompressProcess.StartInfo.Arguments = «...»;
string so = CompressProcess.StandardOutput.ReadToEnd();
CompressProcess.WaitForExit();
// Convert cp866 data -> textbox
public static string Convert(string value, Encoding src, Encoding trg)
{
Decoder dec = src.GetDecoder();
byte[] ba = trg.GetBytes(value);
int len = dec.GetCharCount(ba, 0, ba.Length);
char[] ca = new char[len];
dec.GetChars(ba, 0, ba.Length, ca, 0);
return new string(ca);
}
static private string EncodeMessageForConsoleOutput(string Message)
{
if (MemoLog == null)
return Message;
return Convert(Message, Encoding.GetEncoding("cp866"), Encoding.Default);
}