OpenFileDialog openFileDialog1 =new OpenFileDialog();
openFileDialog1.Filter = "gif(*.gif)|*.gif";
openFileDialog1.RestoreDirectory = true;
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
MessageBox.show(openFileDialog1.FileName);
}

解决方案 »

  1.   

    if(openFileDialog1.ShowDialog()==DialogResult.OK)
    {
    }saveFileDialog类似
      

  2.   

    SaveFileDialog SaveFileDialog1 =new SaveFileDialog();
    SaveFileDialog1.Filter = "编码器会话文件 (*.wme)|*.wme";
    SaveFileDialog1.RestoreDirectory = true;
    if (SaveFileDialog1.ShowDialog() == DialogResult.OK)
    {
    //存储源组配置文件到指定路径。
    Encoder1.Save(SaveFileDialog1.FileName);
    }
      

  3.   

    晕~~~我要求它们在richTextBox中显示啊。可是上面的显示不出啊。
      

  4.   

    //上传附件
    HttpPostedFile hpf=htmlInputFile.PostedFile;
    char[] de={'\\'};
    string[] AFilename=hpf.FileName.Split(de);
    strflsize=hpf.ContentLength.ToString();//附件大小
    strFlName="";//附件名
    strFlName=AFilename[AFilename.Length-1];
    if(hpf != null)
    {//文件存在
    hpf.SaveAs(Server.MapPath("../FileFolder/")+docmid.ToString()+strFlName);
    //保存文件
    file="(服务器相对路径)/FileFolder/"+docmid.ToString()+strFlName;
    //文件保存路径
    //-------------在数据库中保存此路径
    }
    else
    {
    file="";
    }//下载附件
    hlkfile.NavigateUrl="http://"+(读数据库中保存的路径).ToString();
      

  5.   

    hlkfile为HyperLink控件
      

  6.   

    有看清我的问题吗?是有那两个控件实现在richTextBox的打开和保存啊。~~~~~`
      

  7.   

    保存文件:
    public void SaveMyFile()
    {
       // Create a SaveFileDialog to request a path and file name to save to.
       SaveFileDialog saveFile1 = new SaveFileDialog();   // Initialize the SaveFileDialog to specify the RTF extension for the file.
       saveFile1.DefaultExt = "*.txt";
       saveFile1.Filter = "Text Files|*.txt";   // Determine if the user selected a file name from the saveFileDialog.
       if(saveFile1.ShowDialog() == System.Windows.Forms.DialogResult.OK &&
          saveFile1.FileName.Length > 0) 
       {
          // Save the contents of the RichTextBox into the file.
          richTextBox1.SaveFile(saveFile1.FileName, RichTextBoxStreamType.PlainText);
       }
    }
    打开文件:
    public void LoadMyFile()
    {
       // Create an OpenFileDialog to request a file to open.
       OpenFileDialog openFile1 = new OpenFileDialog();   // Initialize the OpenFileDialog to look for RTF files.
       openFile1.DefaultExt = "*.txt";
       openFile1.Filter = "Text Files|*.txt";   // Determine whether the user selected a file from the OpenFileDialog.
       if(openFile1.ShowDialog() == System.Windows.Forms.DialogResult.OK &&
          openFile1.FileName.Length > 0) 
       {
          // Load the contents of the file into the RichTextBox.
          richTextBox1.LoadFile(openFile1.FileName, RichTextBoxStreamType.PlainText);
       }
    }