易截截图软件、单文件、免安装、纯绿色、仅160KB

在ASP.NET中上传图片并生成缩略图

private void btnUploadPicture_Click(object sender, System.EventArgs e)
{
   //检查上传文件的格式是否有效
   if(this.UploadFile.PostedFile.ContentType.ToLower().IndexOf("image") < 0)
   {
    Response.Write("上传图片格式无效!");
    return;
   }
   //生成原图
   Byte[] oFileByte = new byte[this.UploadFile.PostedFile.ContentLength];
   System.IO.Stream oStream = this.UploadFile.PostedFile.InputStream;
   System.Drawing.Image oImage = System.Drawing.Image.fromStream(oStream);
   int oWidth = oImage.Width; //原图宽度
   int oHeight = oImage.Height; //原图高度
   int tWidth = 100; //设置缩略图初始宽度
   int tHeight = 100; //设置缩略图初始高度
   //按比例计算出缩略图的宽度和高度
   if(oWidth >= oHeight)
   {
    tHeight = (int)Math.Floor(Convert.ToDouble(oHeight) * (Convert.ToDouble(tWidth) / Convert.ToDouble(oWidth)));
   }
   else
   {
    tWidth = (int)Math.Floor(Convert.ToDouble(oWidth) * (Convert.ToDouble(tHeight) / Convert.ToDouble(oHeight)));
   }
   //生成缩略原图
   Bitmap tImage = new Bitmap(tWidth,tHeight);
   Graphics g = Graphics.fromImage(tImage);
   g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High; //设置高质量插值法
   g.SmoothingMode = System.Drawin


相关文档:

ASP.net使用URL传递中文参数

ASP.NET用URL传递中文参数一般会失败,原因是在获取参数之后进行了编译转换。
可能过修改web.config文件让URL正常传递中文参数
在System.web节添加
<globalization requestEncoding="gb2312" responseEncoding="gb2312" culture="zh-CN" fileEncoding="gb2312"/>

即可 ......

asp.net为啥要引用configSections?

因为用户的一些对象, 可能在config里进行配置, 但是config怎么能随便让你添加自己的节点呢! 不行你自己试试, 在任何位置添加任何没有申明的节点, 系统都不会让你通过, 更不会让你去读它了, 当然, 你打算在别的xml文件里添加节点, 然后读出来, 创建对象, 这个没问题. 为了系统能有组织的管理用户的在配置文件里的自定义信息 ......

asp.net生成静态页面

public static void GetHtml(string url,string savepath)//url参数为将要生成的那个动态页面的地址,savepath为要存放地址
{
string Result;
WebResponse MyResponse;
WebRequest MyRequest = System.Net.HttpWebRequest.Create(url);
MyResponse = MyReque ......

asp.net调用bat文件

引用命名空间
using System.Diagnostics;
                string sPath = "d:\\test\\test.bat";
string sDict = "d:\\test\\";
ProcessStartInfo psi = new ProcessStartInfo("cmd.exe ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号