asp.net 图片处理 获取图片宽度和高度
1.获取图片宽度和高度
1.您可以使用 System.Drawing.Image 类
System.Drawing.Image img = System.Drawing.Image.fromFile(Server.MapPath("example.gif"));
int width = img.Width;
int height = img.Height;
img.Dispose();
但是这里我们却不能在导入名称空间后使用 Image 时省略 System.Drawing,因为这会和 System.Web.UI.WebControls 的 Image 产生混淆。
或者您也可以使用 System.Drawing.Bitmap 类
Bitmap bmp = new Bitmap(Server.MapPath("example.jpg"));
int width = bmp.Width;
int height = bmp.Height;
bmp.Dispose();
虽然名称是 Bitmap,但实际同样可以处理 BMP、JPEG、GIF、PNG 等格式的图片。
那么 System.Drawing.Image 和 System.Drawing.Bitmap 有什么区别呢?
System.Drawing.Image 其实是 System.Drawing.Bitmap 的基类,这就是为什么 Bitmap 不单单可以处理 BMP 图片的原因了。
相关文档:
web.config:
<system.net>
<mailSettings>
<smtp deliveryMethod="Network" from="chunyou128<you@163.com>">
&n ......
关闭窗体
1.
this.btnClose.Attributes.Add("onclick", "window.close();return false;");
2.关闭本窗体间跳转到另一个页面
this.HyperLink1.NavigateUrl = "javascript:onclick=window.opener.location.assign
......
上次做了个项目,涉及到数据库的还原和恢复,到网上找了一下,是利用SQLDMO实现的,只要添加SQLDMO引用就好了,然后利用下边的类的方法就可以实现了。
我把原作者的类扩充了一下,可以自动识别web.config里 的数据库连接字符串,可以通过变量设置还原恢复的信息。
需要注意的时还原,还原的时候问题最大了,有别 ......
在Asp.Net中写了一个附件上传和下载的程序,附件上传到数据库中,然后将附件的GUID保存起来,我们可以根据GUID来找到数据库中的附件,一般附件下载的代码是:
private void Download(string ID)
{
file = logic.GetA ......
<%@ Page Language="C#" %>
<%@ Import Namespace="System.IO" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
prote ......