Random ran = new Random();
int i = ran.Next(100,500);
string imastr=newpath.Replace("_","")+i.ToString()+"."+nam;
string imadbstr="photo/"+imastr;
myFile.PostedFile.SaveAs(Server.MapPath(imadbstr));
System.Drawing.Image image = System.Drawing.Image.FromFile(Server.MapPath(imadbstr));
System.Drawing.Image image1 = image;
image1 = image1.GetThumbnailImage(200,150,null,IntPtr.Zero);
string newsmallfile="small"+imastr;
string newsmallima="photo/"+newsmallfile;
image1.Save(Server.MapPath(newsmallima));
image.Dispose();
image1.Dispose();UP图片 一同得到小图片
正常
现在想在保存图片时候 做个判断
把如下代码放在上面代码之下
if(可以寸)
{
myFile.PostedFile.SaveAs(Server.MapPath(imadbstr));
image1.Save(Server.MapPath(newsmallima));
image.Dispose();
image1.Dispose();}
else
{
不存
}
结果
异常详细信息: System.IO.FileNotFoundException: F:\aaa\photo\member_photo\2005922162.gif
源错误: System.Drawing.Image image = System.Drawing.Image.FromFile(Server.MapPath(imadbstr));
int i = ran.Next(100,500);
string imastr=newpath.Replace("_","")+i.ToString()+"."+nam;
string imadbstr="photo/"+imastr;
myFile.PostedFile.SaveAs(Server.MapPath(imadbstr));
System.Drawing.Image image = System.Drawing.Image.FromFile(Server.MapPath(imadbstr));
System.Drawing.Image image1 = image;
image1 = image1.GetThumbnailImage(200,150,null,IntPtr.Zero);
string newsmallfile="small"+imastr;
string newsmallima="photo/"+newsmallfile;
image1.Save(Server.MapPath(newsmallima));
image.Dispose();
image1.Dispose();UP图片 一同得到小图片
正常
现在想在保存图片时候 做个判断
把如下代码放在上面代码之下
if(可以寸)
{
myFile.PostedFile.SaveAs(Server.MapPath(imadbstr));
image1.Save(Server.MapPath(newsmallima));
image.Dispose();
image1.Dispose();}
else
{
不存
}
结果
异常详细信息: System.IO.FileNotFoundException: F:\aaa\photo\member_photo\2005922162.gif
源错误: System.Drawing.Image image = System.Drawing.Image.FromFile(Server.MapPath(imadbstr));
解决方案 »
- 正则表达式的问题
- 关于强类型DataSet
- asp.net+sql2000+ajax response.write
- 请教:看了些文章.ascx文章中能包含部分WEB窗体控件如Repeater等。却不能包含Button等
- 自定义TreeNode,如何取出自定义的属性?
- Datagrid疑问?
- 大家帮忙解决一个问题,对我来说简直是“致命问题”
- 急.............TEXTBOX控件输出问题
- 通过 Controls.Add() 方法动态创建的控件为什么在 Postback 或者刷新的时候又不见了??
- 不明白
- 请教高手!如何在WEB项目里调用windows项目????
- 通用类的调用什么时候需要NEW,什么时候不用???
这个文件没有找到
string imastr=newpath.Replace("_","")+i.ToString()+"."+nam;
即不加下面的IF ELSE
就OK
int i = ran.Next(100,500);
string imastr=newpath.Replace("_","")+i.ToString()+"."+nam;
string imadbstr="photo/"+imastr;
myFile.PostedFile.SaveAs(Server.MapPath(imadbstr));
System.Drawing.Image image = System.Drawing.Image.FromFile(Server.MapPath(imadbstr));
System.Drawing.Image image1 = image;
image1 = image1.GetThumbnailImage(200,150,null,IntPtr.Zero);
string newsmallfile="small"+imastr;
string newsmallima="photo/"+newsmallfile;
image1.Save(Server.MapPath(newsmallima));
image.Dispose();
image1.Dispose();以上代码 运行非常OK
该成IF ELSE 就非常不OK!!!
大概思路是if(判断数据表该用户发了几张图片)
{保存}
else
{不保存}