我正在尝试使用 OpenFileDialough 在 picturebox 中加载图像,但它不起作用我如何获取 Openfiledialough 的路径以及如何加载它

I'm trying to load image in picturebox using OpenFileDialough but it's not working how i get path of Openfiledialough And how to load it

openFileDialog1.Filter = "JPEG (*.jpg)|*.jpg|PNG (*.png)|*.png|GIF (*.gif)|*.gif";
openFileDialog1.ShowDialog();
string name = openFileDialog1.FileName;
FileInfo F = new FileInfo(name);
string path = F.DirectoryName.ToString();
pictureBox1.Load(path);
OpenDialog.Reset();
OpenDialog.AutoUpgradeEnabled = true;
OpenDialog.CheckFileExists = true;
OpenDialog.CheckPathExists = true;
OpenDialog.DefaultExt = "";
OpenDialog.FileName = "";
OpenDialog.Filter = "Images (.jpeg)|*.jpg;*.jpeg";
OpenDialog.InitialDirectory = @"C:\";
OpenDialog.Multiselect = false;
OpenDialog.RestoreDirectory = false;
OpenDialog.ShowHelp = false;
OpenDialog.ShowReadOnly = false;
OpenDialog.Title = this.Text;

if (OpenDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
    Image productimage = Image.FromFile(OpenDialog.FileName);
    System.Drawing.Size defaultsize = new Size(129, 129);

    if (productimage.Width > defaultsize.Width || productimage.Height > defaultsize.Height)
    {
        Common.ShowErrorMessage("Cannot load large image. Default size (128 X 128)", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
        return;
    }
    PicBox.Image = productimage;
}