Jump to content
Tatia

Como visualizar consola em um textbox?

Recommended Posts

Tatia

Boas amigos gostaria de saber como faço para visualizar os valores da consola em um textbox?

Ou seja queria manipular a consola mas dentro de um textbox...

Podem me ajudar?

Edited by Tatia

Share this post


Link to post
Share on other sites
Tatia

o CMD

Mas o pretendido seria usar um programa que e executado na consola...

Edited by Tatia

Share this post


Link to post
Share on other sites
NoLabel


//Criar objecto com as propriedades para iniciar processo
ProcessStartInfo procInfo = new ProcessStartInfo();

//Localização do ficheiro
//@ = literal string
procInfo.FileName = @"localização do ficheiro";

//Se UseShellExecute == true então vai chamar a API ShellExecute, se == false vai chamar a API CreateProcess
procInfo.UseShellExecute = false;

//Redireccionar o output
procInfo.RedirectStandardOutput = true;

//Iniciar processo
using (Process process = Process.Start(procInfo))
{

//Ler o output com o streamReader
using (StreamReader objReader = process.StandardOutput)
{
string result = objReader.ReadToEnd();
MessageBox.Show(result);
}
}

Nota: a using statment garante que todos os recursos serão libertados após a utilização.

Edited by thoga31
GeSHi

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.