上传图片路径

时间:2013-02-16 15:16:36

标签: c# winforms

我需要获取图像路径..以便我可以将其存储在我的数据库中..

有人可以帮助我吗?

这是我的代码..

private void button14_Click(object sender, EventArgs e)
        {
            if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                System.IO.StreamReader sr = new System.IO.StreamReader(openFileDialog1.FileName);
                MessageBox.Show(sr.ReadToEnd());
                sr.Close();
            }
        }

消息框显示异类内容..我需要显示的msgbox是所选图像的路径..

1 个答案:

答案 0 :(得分:0)

if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
    {
        MessageBox.Show((new System.IO.FileInfo(openFileDialog1.FileName)).DirectoryName +  openFileDialog1.FileName);
    }