我如何...使用文本框文本 [英] How do I...use textbox text

查看:69
本文介绍了我如何...使用文本框文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好:)

在我的程序中,我有文本框,用户将填写他的用户名密码和电子邮件

我要做的是保存这些信息对于文本文件中的每个用户。

所以我这样做了:

流阅读器fr =新流阅读器(myfile.txt);

string [] chaine = new string [4];

chaine [0] = textox1.text.tostring();

fr.writeline(chaine [0] );



但是当我输入文件时没有添加任何内容

我的代码有什么问题吗?

提前谢谢你

hello:)
in my program, I have textboxes that the user will fill with his username password and email
what I what to do is to save these info for each user in a text file.
so I did this:
stream reader fr=new stream reader("myfile.txt");
string[]chaine=new string[4];
chaine[0]=textox1.text.tostring();
fr.writeline(chaine[0]);

but when I enter the file there's nothing add
is there anything wrong in my code?
thank you in advance

推荐答案

如果你想在文本文件中添加文本框的值,只需使用:



If you want to add the textboxes' values in a text file, simply use:

private void button1_Click(object sender, EventArgs e)
        {
            StreamWriter sw = new StreamWriter("test.txt");
            sw.WriteLine(textBox1.Text);
            sw.WriteLine(textBox2.Text);
            sw.WriteLine(textBox3.Text);
            sw.Close();
        }





如果你想要它们没有线条(所有元素一个接一个),请使用:



If you want them without lines(all the elements one after each other) use:

private void button1_Click(object sender, EventArgs e)
        {
            StreamWriter sw = new StreamWriter("test.txt");
            sw.Write(textBox1.Text);
            sw.Write(textBox2.Text);
            sw.Write(textBox3.Text);
            sw.Close();
        }





希望这会有所帮助 - CCB



Hope this helps - CCB


这篇关于我如何...使用文本框文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆