日期:2014-05-18  浏览次数:20656 次

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

------解决方案--------------------
C# code
 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;
               
                
            }
        }