服务器上有个图片,我想知道他的宽度,该如何>?例如: a.jpg如何知道他的宽度?

解决方案 »

  1.   


    System.Drawing.Image image = System.Drawing.Image.FromFile(System.Web.HttpContext.Current.Server.MapPath(this._path)); 
    //取高和宽
    int phWidth = image.Width; 
    int phHeight =image.Height;
      

  2.   

    string newpic1=cmd.Parameters["@pic_url_s"].Value.ToString(); string news=""; if (newpic1!="")
    {
    news="<img src=http://mall.chinacars.com/newcars/manage/"+newpic1+">";
    }
    else
    {
    news="<img src=image/nochexing.jpg>"; } System.Drawing.Image image = System.Drawing.Image.FromFile(System.Web.HttpContext.Current.Server.MapPath(news)); //这行错了
    Response.Write("图片宽度:"+image.Width);我项目文件的服务器和图片文件服务器不在同一台服务器上MapPath“<img src=http://mall.chinacars.com/new/20056141612_s.jpg>”的路径无效。应为虚拟路径。