0

我正在尝试使用文件打开对话框打开图像,但收到此错误消息:参数异常 - 路径不是合法形式。

图像怎么可能不是法律形式?

设置图片方法

public void SetPicture(String fileName)
    {
        pictureBox1.Image = Image.FromFile(fileName);
    }

切换语句

  private void ViewButton_Click(object sender, EventArgs e)
    {
        switch (txtMediaType.Text)
        {
            case "Picture":
                PictureViewer p = new PictureViewer();
                p.SetPicture(ofdSelectMedia.FileName);
                p.Show();
                break; 
            case "Video":
                VideoViewer v = new VideoViewer();
                v.SetVideo(ofdSelectMedia.FileName);
                v.Show();
                break;

            case "URL":
                System.Diagnostics.Process.Start(txtFilePath.Text);
                break;
4

0 回答 0