string fullname = openFileDialog1.FileName;
 string path = System.IO.Path.GetDirectoryName( fullname );

解决方案 »

  1.   

                            OpenFileDialog m_OpenFileDialog = new OpenFileDialog();
    m_OpenFileDialog.Title = "打开文件";
    m_OpenFileDialog.Filter = "所有文件 (*.*)|*.*";
    m_OpenFileDialog.FilterIndex = 1;
    m_OpenFileDialog.RestoreDirectory = true;
    m_OpenFileDialog.Multiselect = false; if( DialogResult.OK == m_OpenFileDialog.ShowDialog() )
    {
    tbFilePath.Text = m_OpenFileDialog.FileName;
    }
      

  2.   

    用 System.IO.Path类的
    GetDirectoryName()方法就可以做到获取文件路径
      

  3.   

    string fullname = openFileDialog1.FileName; 
    string path = System.IO.Path.GetDirectoryName( fullname );