做备忘录收获

清空文件内容:

 private void btn_delall_Click(object sender, EventArgs e)
        {
            FileInfo info = new FileInfo(@"F:\ASP.NET\备忘录\a.txt");
             MessageBox.Show("是否要清空您的所有记录","Warning",MessageBoxButtons.YesNo,MessageBoxIcon.Warning);
            info.Delete();
            this.listBox1.Items.Clear();//清空列表
        }//删除全部

浏览备忘录:

 private void btn_scan_Click(object sender, EventArgs e)
        {
            FileStream FStream1 = new FileStream(@"F:\ASP.NET\备忘录\a.txt",FileMode.OpenOrCreate);
            StreamReader sr = new StreamReader(FStream1, System.Text.Encoding.Default);
            string strLine= sr.ReadLine();
            if (strLine == null)
            {
                MessageBox.Show("对不起,您的备忘录中没有数据!");
            }
            else
            {
                while (strLine != null)
                {
                    strLine = sr.ReadLine();
                    if (strLine != null && !strLine.Equals(""))
                        this.listBox1.Items.Add(strLine);
                }
                sr.Close();
            }
           
        }//查看备忘录

定时提醒器:

 private void timer1_Tick(object sender, EventArgs e)
        {
            //this.timer1.Enabled = true;
            label3.Text = string.Format("{0:yyyy/MM/d HH:mm:ss}", DateTime.Now); //获取系统时间 24小时制小时写成大写“HH”,12小时制的小时写成小写的“hh”
            FileStream FStream = new FileStream(@"F:\ASP.NET\备忘录\a.txt",FileMode.Open);
            StreamReader SReader = new StreamReader(FStream,System.Text.Encoding.Default);
            string strLine = SReader.ReadLine();
            while (strLine != null)
            {
                strLine = SReader.ReadLine();
                if (strLine != null && !strLine.Equals(""))
                {
                    string[] read = strLine.Split(' ');
                    string a=label3.Text;
                    string[] str = a.Split(' ');
                    string[] str2 = str[1].Split(':');
                    if (str[0] == read[0].Trim() && str2[0] == read[1].Trim() && str2[1] ==read[2].Trim())
                    {
                        playmusic();
                    }
                }
            }
            SReader.Dispose();
            FStream.Dispose();

}

更换头像:

 private void btn_ChangeH_Click(object sender, EventArgs e)
        {
            if (this.openFileDialog1.ShowDialog()==DialogResult.OK)
            {
                if (this.openFileDialog1.FileName!=null)
                {
                    this.openFileDialog1.ShowDialog();
                    this.pic_Head.Image = Image.FromFile(this.openFileDialog1.FileName);
                }
            }
        }//更换头像

 

 

 

 

 

你可能感兴趣的:(做备忘录收获)