問題1: text1.text="111111";
text2.text="222222";
text3.text="333333";
text4.text="555555";
請問我如何才能實現
江上面的内容存到 data.txt 中格式為
1111111,22222222
3333333,55555555問題2:
完成上面后
從文件中讀取數據
實現tempbutton1的標題為1111111;點擊他后執行22222222
tempbutton2的標題為3333333,點擊后執行55555555
謝謝了!
text2.text="222222";
text3.text="333333";
text4.text="555555";
請問我如何才能實現
江上面的内容存到 data.txt 中格式為
1111111,22222222
3333333,55555555問題2:
完成上面后
從文件中讀取數據
實現tempbutton1的標題為1111111;點擊他后執行22222222
tempbutton2的標題為3333333,點擊后執行55555555
謝謝了!
1.每两个连起来中间加上一个“,”不就可以了
2.按照一定的分割符号分割字符串
String.Split
3.tempbutton1.Text="";
执行使用反射
FileStream fs2=new FileStream("data.txt",FileMode.Create);
StreamWriter swd=new StreamWriter(fs2,Encoding.Default);
string str = text1.text +","+ text2.text + "\r\n";
swd.WriteLine(str);
str = text3.text +","+ text4.text;
swd.Close();
FileStream fs1=new FileStream("data.txt",FileMode.Open);
StreamReader srd=new StreamReader(fs1,Encoding.Default);
string[] strTemp;
while(srd.Peek() != -1)
{
string str = srd.ReadLine() + ",";
}
strTemp = str.Split(',');
this.tempbutton1.Text = strTemp[0];
this.tempbutton2.Text = strTemp[2];//此种方法仅仅针对你明确知道文件存储格式的情况下,否则还是一行一行读然后处理,将strTemp[1]和strTemp[3]存在全局变量中就可以了,或者临时再读也成
srd.Close();