当前位置: 代码迷 >> Web Service >> images中明明有图片为什么在file.exists()时,布尔值为false?解决方法
  详细解决方案

images中明明有图片为什么在file.exists()时,布尔值为false?解决方法

热度:197   发布时间:2016-05-02 02:25:18.0
images中明明有图片为什么在file.exists()时,布尔值为false?
 //要加水印的目标图片
    private const string aimImg="images/DSCF3982(3).jpg";
    //数字水印路径
    private const string waterImg = "images/logonew.jpg";
    //默认图片的路径
    private const string defaultImg = "images/logo.jpg";
    public void ProcessRequest (HttpContext context) {
        Image cover;
        if (File.Exists(aimImg))
        {
------解决方案--------------------
File.Exists()里面判断的是绝对路径、在aimimg前面加上对应的物理路径就行了
------解决方案--------------------
是否使用了UpdatePanel,如果使用会有这种情况。
------解决方案--------------------
if (File.Exists(Server.MapPath(aimImg)))
------解决方案--------------------
路径问题,你要写成(Server.MapPath(aimImg))
  相关解决方案