基本信息
源码名称:c# 通过winform打开控制台 并读取相关数据 例子
源码大小:2.79M
文件格式:.rar
开发语言:C#
更新时间:2015-06-16
友情提示:(无需注册或充值,赞助后即可获取资源下载链接)
嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):78630559
本次赞助数额为: 2 元×
微信扫码支付:2 元
×
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
源码介绍
winform与控制台通讯例子
winform与控制台通讯例子
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Web.Script.Serialization;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
public struct JsonClass
{
public string exchanger { get; set; } //属性的名字,必须与json格式字符串中的"key"值一样。
public string age { get; set; }
public string email { get; set; }
public string QQ { get; set; }
}
private void button1_Click(object sender, EventArgs e)
{
Process process = new Process();
ProcessStartInfo a = new ProcessStartInfo();
a.UseShellExecute = false;
a.RedirectStandardOutput = true;
a.FileName = "cmd.exe";
a.Arguments = "/C" "nslookup -qt=mx nippotusho.co.jp";
process.StartInfo = a;
process.Start();
process.WaitForExit(10);
// StreamReader myStreamReader = process.StandardOutput;
// Read the standard output of the spawned process.
// string myString = myStreamReader.ReadLine();
string asd = process.StandardOutput.ReadToEnd();
//string output = process.StandardOutput.ReadToEnd();//读取进程的输出
// Console.WriteLine(myString);
richTextBox1.Text = asd;
// process.WaitForExit();
string newString2 = asd.Substring(asd.IndexOf(",") 1, asd.Length - (asd.IndexOf(",") 1)); //提取@后的字符串
// string newString1 =newString2.Substring(0, newString2.IndexOf(',')); //提取@前的字符串
// richTextBox2.Text = newString1;
char[] delimiterChars = { ' ', '=' ,'\t','\n'};
string text = newString2;
string[] words = text.Split(delimiterChars);
richTextBox2.Text = words[5];
//string[] AAA = words[5].Split(delimiterChars);
//richTextBox2.Text = AAA[0];
}
}
}