private void Btn_Upload_Click(object sender, System.EventArgs e)
{
if (UploadFile.PostedFile.FileName.Trim() != "")
{
//上传文件
string extension = Path.GetExtension(UploadFile.PostedFile.FileName).ToUpper();
string fileName = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString();
string path = Server.MapPath(".") + "/UploadFile/" + fileName + extension;
UploadFile.PostedFile.SaveAs("C:\\Documents and Settings\\Administrator\\桌面\\光纤\\数字通道.jpg");
//加图片水印
System.Drawing.Image image = System.Drawing.Image.FromFile(path);
System.Drawing.Image copyImage = System.Drawing.Image.FromFile(Server.MapPath(".") + "/Alex.gif");
Graphics g = Graphics.FromImage(image);
g.DrawImage(copyImage, new Rectangle(image.Width - copyImage.Width, image.Height - copyImage.Height, copyImage.Width, copyImage.Height), 0, 0, copyImage.Width, copyImage.Height, GraphicsUnit.Pixel);
g.Dispose(); //保存加水印过后的图片,删除原始图片
string newPath = Server.MapPath(".") + "/UploadFile/" + fileName + "_new" + extension;
image.Save(newPath);
image.Dispose();
if (File.Exists(path))
{
File.Delete(path);
} HttpContext.Current.Response.Redirect(newPath);
这段代码是asp.net的,红色的字是报错:上下文中不存在名称。怎么添加引用啊????using System.IO; 貌似我的里面没有啊!
{
if (UploadFile.PostedFile.FileName.Trim() != "")
{
//上传文件
string extension = Path.GetExtension(UploadFile.PostedFile.FileName).ToUpper();
string fileName = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString();
string path = Server.MapPath(".") + "/UploadFile/" + fileName + extension;
UploadFile.PostedFile.SaveAs("C:\\Documents and Settings\\Administrator\\桌面\\光纤\\数字通道.jpg");
//加图片水印
System.Drawing.Image image = System.Drawing.Image.FromFile(path);
System.Drawing.Image copyImage = System.Drawing.Image.FromFile(Server.MapPath(".") + "/Alex.gif");
Graphics g = Graphics.FromImage(image);
g.DrawImage(copyImage, new Rectangle(image.Width - copyImage.Width, image.Height - copyImage.Height, copyImage.Width, copyImage.Height), 0, 0, copyImage.Width, copyImage.Height, GraphicsUnit.Pixel);
g.Dispose(); //保存加水印过后的图片,删除原始图片
string newPath = Server.MapPath(".") + "/UploadFile/" + fileName + "_new" + extension;
image.Save(newPath);
image.Dispose();
if (File.Exists(path))
{
File.Delete(path);
} HttpContext.Current.Response.Redirect(newPath);
这段代码是asp.net的,红色的字是报错:上下文中不存在名称。怎么添加引用啊????using System.IO; 貌似我的里面没有啊!
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货