显示文件夹中的图像? [英] display image from folder ?

查看:76
本文介绍了显示文件夹中的图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我想从我的项目中未包含的文件夹中的图像控件中显示图像.我怎样才能做到这一点?我正在提供我正在使用的代码,但它不起作用...请指导该代码出了什么问题..请记住,文件夹(Uploads)未包含在我的项目文件中,并且我不想包含该文件夹还有...

Hi,
I want to display an image in my image control from a folder that is not included in my project. how can i do that? I am giving the code i am using but it is not working...Pleas guide what is wrong with that code..Remember that folder(Uploads) is not included in my project file and I don''t want to include that folder as well...

string path = Server.MapPath("~/Uploads/Chrysanthemum_3.jpeg");
imgPicture.ImageUrl = path;

推荐答案

(如果它是服务器端控件).您需要设置虚拟路径.

Server.MapPath(.")返回正在执行的文件(例如aspx)的当前物理目录.
Server.MapPath("..")返回父目录
Server.MapPath(〜")返回到应用程序根目录的物理路径.
Server.MapPath("/")返回到域名根的物理路径(不一定与应用程序的根相同)

使用
if its a server side control. you need to set the virtual path.

Server.MapPath(".") returns the current physical directory of the file (e.g. aspx) being executed
Server.MapPath("..") returns the parent directory
Server.MapPath("~") returns the physical path to the root of the application
Server.MapPath("/") returns the physical path to the root of the domain name (is not necessarily the same as the root of the application)

use
string path = Server.MapPath("~") + "/Uploads/Chrysanthemum_3.jpeg"; <br />
imgPicture.ImageUrl = path;


这篇关于显示文件夹中的图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆