我在做一个仿WINDOWS记事本程序,打开文件时文件的文件名自动显示在 Form1的Text上 不知道怎么弄   各位高手请帮下忙   小弟 在线等谢谢

解决方案 »

  1.   


    string strFilePaht="文件路径"; 
    Path.GetFileNameWithoutExtension(strFilePath);
      

  2.   

     private void 打开Button_Click(object sender, EventArgs e)
            { 
                openFileDialog1.DefaultExt = "*.rtf";
                openFileDialog1.Filter = "RTF Files|*.rtf|(*.txt)|*.txt";
                openFileDialog1.FilterIndex = 2;
                openFileDialog1.RestoreDirectory = true;            if (openFileDialog1.ShowDialog() == DialogResult.OK && openFileDialog1.FileName.Length > 0)
                {
                    string filname = openFileDialog1.FileName;
                    textBox1.Text=filname;
                   
                    
                }
            }
      

  3.   

    做记事本 不能用 ShowDialog()吧。获得文件名fileName之后Form1.Text=fileName;
      

  4.   

    引用#3楼
    做记事本 不能用 ShowDialog()吧。还是用的好,当选择打开电脑上的文件时用的上
    上面写是在textbox上的,要在Form1上用
    Form1.Text=filname;