当前位置:编程学习 > C#/ASP.NET >>

C#编程中怎样编写在用户名登录框中记录曾经登录过的用户的用户名?

C#编程中怎样编写在用户名登录框中记录曾经登录过的用户的用户名?
答案:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
namespace WindowsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button2_Click(object sender, EventArgs e)
{
FileStream fs = new FileStream("d://g1.bin", FileMode.Create);
BinaryWriter w = new BinaryWriter(fs);
for (int i = 0; i < 10; i++)
w.Write(i);
w.Close();
}

private void button3_Click(object sender, EventArgs e)
{
FileStream fs = new FileStream("d://g1.bin", FileMode.Open);
BinaryReader r = new BinaryReader(fs);
r.ReadChar();
r.Close();
listBox1.MultiColumn = false;
listBox1.Items.Add(textBox1.Text);
}

private void button1_Click(object sender, EventArgs e)
{
byte[] data = new byte[10];
for (int i = 0; i < 10; i++)
data[i] = (byte)i;
FileStream fs = new FileStream("d://g1.bin", FileMode.Create);
fs.Write(data, 0, 10);
textBox1.Text = "";
fs.Close();

}
}
}
web程序的话直接使用登陆控件,里面有记录cookie
如果是winform程序 就需要写入文件保存
方法有很多!
根据你的说法,可以记录个登录时间,判断在多少时间内该用户登录过.
或者是写如数据库,当有用户再次登录,就操作其数据库,实现你想要的效果.

上一个:用C#编程怎么样实现提取原始的物理MAC地址(不是更改过的MAC地址)
下一个:给介绍几本c#网络编程书籍?

CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,