FileStream fs = new FileStream("D:\\updateIP\\UPdateIP.bat", FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
StreamReader sr = new StreamReader(fs, Encoding.Default);
string all;
string name;
string source;
string addr;
string mask;
string gateway;
string gwmetric;
do
{
all = sr.ReadLine();
if (all != "" && all != null && all.Substring(0, 5) == "netsh")
{
name = all.Substring(all.IndexOf("\"") + 1, all.IndexOf("\" ") - all.IndexOf("\"") - 1);
source = all.Substring(all.IndexOf("ce=") + 3, all.IndexOf(" addr=") - all.IndexOf("ce=") - 3);
addr = all.Substring(all.IndexOf("r=") + 2, all.IndexOf(" m") - all.IndexOf("r=") - 2);
mask = all.Substring(all.IndexOf("k=") + 2, all.IndexOf(" g") - all.IndexOf("k=") - 2);
gateway = all.Substring(all.IndexOf("y=") + 2, all.IndexOf(" gw") - all.IndexOf("y=") - 2);
gwmetric = all.Substring(all.IndexOf("c=") + 2);
this.TextBox1.Text = name;
this.TextBox5.Text = addr;
this.TextBox9.Text = mask;
this.TextBox13.Text = gateway;
这段代码是输出
@echo off
netsh interface ip set address name="LAN2" source=static addr=192.168.0.151 mask=255.255.255.0 gateway=192.168.0.10
gwmetric=auto
netsh interface ip set address name="LAN3" source=static addr=192.168.20.16 mask=255.255.255.0 gateway=192.168.0.10
gwmetric=auto
这个文本文件里的LAN2 192.168.0.151 255.255.255.0 192.168.0.10 LAN3 192.168.20.16 255.255.255.0 192.168.0.10这些内容 要将这些内容输出到对应的文本框中有8个文本框 但现在只能输出一行对应的数据 我想将其输出到对应的文本框中 该怎么实现呢 请大家指教
StreamReader sr = new StreamReader(fs, Encoding.Default);
string all;
string name;
string source;
string addr;
string mask;
string gateway;
string gwmetric;
do
{
all = sr.ReadLine();
if (all != "" && all != null && all.Substring(0, 5) == "netsh")
{
name = all.Substring(all.IndexOf("\"") + 1, all.IndexOf("\" ") - all.IndexOf("\"") - 1);
source = all.Substring(all.IndexOf("ce=") + 3, all.IndexOf(" addr=") - all.IndexOf("ce=") - 3);
addr = all.Substring(all.IndexOf("r=") + 2, all.IndexOf(" m") - all.IndexOf("r=") - 2);
mask = all.Substring(all.IndexOf("k=") + 2, all.IndexOf(" g") - all.IndexOf("k=") - 2);
gateway = all.Substring(all.IndexOf("y=") + 2, all.IndexOf(" gw") - all.IndexOf("y=") - 2);
gwmetric = all.Substring(all.IndexOf("c=") + 2);
this.TextBox1.Text = name;
this.TextBox5.Text = addr;
this.TextBox9.Text = mask;
this.TextBox13.Text = gateway;
这段代码是输出
@echo off
netsh interface ip set address name="LAN2" source=static addr=192.168.0.151 mask=255.255.255.0 gateway=192.168.0.10
gwmetric=auto
netsh interface ip set address name="LAN3" source=static addr=192.168.20.16 mask=255.255.255.0 gateway=192.168.0.10
gwmetric=auto
这个文本文件里的LAN2 192.168.0.151 255.255.255.0 192.168.0.10 LAN3 192.168.20.16 255.255.255.0 192.168.0.10这些内容 要将这些内容输出到对应的文本框中有8个文本框 但现在只能输出一行对应的数据 我想将其输出到对应的文本框中 该怎么实现呢 请大家指教
解决方案 »
- JQuery ie中报变量未定义 奇怪
- jquery-pagination分页ajax+分页存储过程
- 关于asp.net中关于DropDownList1绑定问题,最后3分献上
- FileUpload 未将对像引用到实例,马上结
- 奇怪问题,请大家帮忙看看!!!
- vs2005中能web窗体继承么?
- 高分解决FreeTextBox 3.1.6插入链接不好用的问题。
- 几个asp小问题???????????????
- 急问:HttpResponse的方法断续下载文件,是不是不支持下载mht格式的文件呀?
- 为什么这样:当 Multiple 为假时,HtmlSelect 不能有多个选定项?
- 我日死microsoft害我搞了一个上午
- 怎样把数据库显示在TextBox上的空格去掉!
source = all.Substring(all.IndexOf("ce=") + 3, all.IndexOf(" addr=") - all.IndexOf("ce=") - 3);
addr = all.Substring(all.IndexOf("r=") + 2, all.IndexOf(" m") - all.IndexOf("r=") - 2);
mask = all.Substring(all.IndexOf("k=") + 2, all.IndexOf(" g") - all.IndexOf("k=") - 2);
gateway = all.Substring(all.IndexOf("y=") + 2, all.IndexOf(" gw") - all.IndexOf("y=") - 2); 你这些都正确获取到值了么
另外你的截取也是只取一行,建议你改进截取方法.
把这个串按照空格进行拆分,就可以得到八个对应的内容,然后再依次赋值到相应的textbox里.