【发布时间】:2020-03-27 03:21:40
【问题描述】:
有没有办法在文件对话框中选择后获取图像目录路径
示例C:\Users\Admin\Desktop\IMG\pix200.jpg
我有一个代码可以在选择图像并在 PictureBox 中显示图像之后打开文件对话框 如前所述,我需要获取图像位置或路径目录
private void student_Edit_PictureBox_Front_DoubleClick(object sender, EventArgs e)
{
OpenFileDialog openFD = new OpenFileDialog();
openFD.Filter = "Bitmaps|*.bmp|jpeg|*.jpg";
if (openFD.ShowDialog() == DialogResult.OK)
{
student_Picture_Edit.Image = Bitmap.FromFile(openFD.FileName);
student_Edit_PictureBox_Front.Image = Bitmap.FromFile(openFD.FileName);
//I want to get the directory path Picturebox.Imagelocation is not working for me
}
}
有解决办法吗?
【问题讨论】:
-
这应该可以解决您的问题stackoverflow.com/questions/439007/…
-
PictureBox 不会知道图片来自哪个路径;所以你需要在加载时存储它。
标签: c#