就是像系统自带的记事本,它的新建和另存为是如何实现的?
还有就是,opendialog和savedialog如何用呢?
谢谢了

解决方案 »

  1.   


                openFileDialog1.Filter = "文本|*.txt";
                if (openFileDialog1.ShowDialog() == DialogResult.OK)
                {
                    string _OpenFilePath = openFileDialog1.FileName;
                }            saveFileDialog1.Filter = "文本|*.txt";
                if (saveFileDialog1.ShowDialog() == DialogResult.OK)
                {
                    string _SaveFilePath = saveFileDialog1.FileName;
                }
      

  2.   

    新建就是把输入框清空,保存就是直接保存,另存为就是调用saveFileDialog获取路径后保存
      

  3.   

    就是像系统自带的记事本,它的新建和另存为是如何实现的? 
    给你的Form添加MenuStrip还有就是,opendialog和savedialog如何用呢? OpenFileDialog openFileDialog = new OpenFileDialog();
     string  FileName;
                 if  ( this .openFileDialog1.ShowDialog()  ==  DialogResult.OK)
                  {
                  FileName  =   this .openFileDialog1.FileName;
                   if  (FileName  !=   "" )
                    {
                     this .pictureBox1.Image  =  Image.FromFile(FileName);
                  } 
                } 
    SaveFileDialog dlg = new SaveFileDialog();if (dlg.ShowDialogue() == DialogueResult.OK)
    {
         dlg.FileName = fileName;
         // ........
          return dlg.FileName; // Don't return that first filename string

      

  4.   

    TextBox 控件, 选择多行属性.  存在数据库中
      

  5.   

    openFileDialog1.Filter = "文本|*.txt"; 
                if (openFileDialog1.ShowDialog() == DialogResult.OK) 
                { 
                    string _OpenFilePath = openFileDialog1.FileName; 
                }             saveFileDialog1.Filter = "文本|*.txt"; 
                if (saveFileDialog1.ShowDialog() == DialogResult.OK) 
                { 
                    string _SaveFilePath = saveFileDialog1.FileName; 
                }记事本使用RICHTEXT
      

  6.   

    下面的代码能够实现读写文本文件的功能
     //打开文本文件并将指定路径下的文件内容读出到文本框中
                OpenFileDialog ofd = new OpenFileDialog();//
                ofd.Filter = "txt.txt|*.txt";
               
                if(ofd.ShowDialog()==DialogResult.OK)
                {
                string ofilepath = ofd.FileName;
                StreamReader sr = new StreamReader(ofilepath,Encoding.GetEncoding("GB2312"));
                this.txtBoxNotepad.Text = sr.ReadToEnd();//txtBoxNotepad文本框
                sr.Close();
                }
      //文本框的内容写入到指的定路径
                SaveFileDialog sfd = new SaveFileDialog();
                sfd.Filter = "txt.txt|*.txt";
                if(sfd.ShowDialog()==DialogResult.OK)
                {
                    string sfilepath = sfd.FileName;
                    StreamWriter sw = new StreamWriter(sfilepath, true, Encoding.GetEncoding("GB2312"));
                    sw.WriteLine(this.txtBoxNotepad.Text);
                    sw.Flush();
                }   
    可以将保存的内容插入到数据库中