EKsumic's Blog

let today = new Beginning();

Click the left button to use the catalog.

OR

C#用ImageLocation获取不到pictureBox控件中图像的路径

情况描述:

控件中的图像是动态添加的
picbox1.Image=Image.FromFile(); //添加图片的代码,运行程序图片可以显示
但是,当我使用picbox1.ImageLocation 调用picbox1中的图片路径的时候,返回的却是一个空值。

解答:

ImageLocation是用来设置或者获取picturebox中要显示的图片路径的,当你用image.fromfile读入文件的之后,这个读入的image对象就跟图片路径之间没有任何关系了,你用imagelocation当然也是得不到值的,当然,如果你用的是picturebox1.Load ("xxx.jpg")这种来载入图片的话,用imagelocation是可以得到图片路径的。

 

参考来源:

https://zhidao.baidu.com/question/572747921.html

This article was last edited at 2020-08-21 23:23:32

* *