婆罗门
精华
|
战斗力 鹅
|
回帖 0
注册时间 2011-4-4
|
- public Form1()
- {
- InitializeComponent();
- string[] flist = Directory.GetDirectories("d:\", "*");
- listBox1.Items.AddRange(flist);
- string result = JsonConvert.SerializeObject(flist);
- using (var fs = new StreamWriter("d:\\filelist.txt", false,Encoding.UTF8))
- {
- fs.Write(result);
- }
- }
- private void button1_Click(object sender, EventArgs e)
- {
- using (var fs = new StreamReader("d:\\filelist.txt", Encoding.UTF8))
- {
- string result = fs.ReadToEnd();
- var flist = JsonConvert.DeserializeObject<string[]>(result);
- listBox1.Items.AddRange(flist);
- }
- }
- private void button2_Click(object sender, EventArgs e)
- {
- listBox1.Items.Clear();
- }
复制代码 |
|