I created an open file dialog to open an image from my computer and than display the picture in the picture box and it's path in a textbox.. The problem is that it is not getting the whole path in the text box example if teh path is:
C:\Users\Anna Marie\Desktop\Software Project Assignment\Images\Pictures\ChickenSalad.jpg
it is giving me the path without the image name:
C:\Users\Anna Marie\Desktop\Software Project Assignment\Images\Pictures\
This is my code:
private void ItemPictureDialog()
{
OpenFileDialog openFileDialog1 = new OpenFileDialog();
openFileDialog1.InitialDirectory = "Libraries\\Documents";
openFileDialog1.Filter = "(*.jpg; *.jpeg; *.gif; *.bmp, *.png)|*.jpg; *.jpeg; *.gif; *.bmp; *.png";
openFileDialog1.FilterIndex = 2;
openFileDialog1.RestoreDirectory = true;
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
picItem.ImageLocation = openFileDialog1.FileName;
txtImagePath.Text = System.IO.Path.GetDirectoryName(openFileDialog1.FileName);
}
}
private void btnBrowsePicture_Click(object sender, EventArgs e)
{
ItemPictureDialog();
}
I can't figure it out could you help me pls?