private void openFileDialog_FileOk(object sender, System.ComponentModel.CancelEventArgs e)
{
try
{
//我想通过openFileDialog在rtfTex中显示打开的文件,参 数怎么弄?
this.rtfText.LoadFile();


}
catch(System.IO.FileNotFoundException)
{
MessageBox.Show("No file to load yet");
}
}

解决方案 »

  1.   

    private void openFileDialog_FileOk(object sender, System.ComponentModel.CancelEventArgs e)
    {
    try
    {
    this.rtfText.LoadFile(openFileDialog.FileName);//Use file name from open-dialog
    }
    catch(System.IO.FileNotFoundException)
    {
    MessageBox.Show("No file to load yet");
    }
    }
      

  2.   

    OpenFileDialog cOpenFileDialog = new OpenFileDialog();
    cOpenFileDialog.Filter = "wav files (*.wav)|*.wav|mp3 files (*.mp3)|*.mp3";
    cOpenFileDialog.FilterIndex = 1;if (cOpenFileDialog.ShowDialog() == DialogResult.OK)
    {
        if (cOpenFileDialog.FileName == null || cOpenFileDialog.FileName == "")
        {
    MessageBox.Show("Please select a file.");
    return;
        }
        if (File.Exists(cOpenFileDialog.FileName) == false)
        {
    MessageBox.Show("The picture file is not exist.");
    return;
        }
        if (LoadVoiceFile(cOpenFileDialog.FileName) != SYS_RETURN.OK)
    MessageBox.Show("Fail to open picture file.");
    }