问题描述
上传发生错误!原因:System.IO.FileNotFoundException:C:DocumentsandSettingsnew桌面肖像4.jpg在System.Drawing.Image.FromFile(Stringfilename,BooleanuseEmbeddedColorManagement)在System.Drawing.Image.FromFile(Stringfilename)在Regedit.ImageThumbnail..ctor(StringImageFileName)位置d:freehostlianght7924webRegedit.aspx.vb:行号171在Regedit.ButtonTJ_Click(Objectsender,EventArgse)位置d:freehostlianght7924webRegedit.aspx.vb:行号100
解决方案
解决方案二:
你的文件路径错了,好好检查一下怎么设置的?
解决方案三:
路径错了。
解决方案四:
路径问题,最好用~
解决方案五:
asp.net2.0我就是把图片上传到photo文件夹代码:try{if(FileUpload1.PostedFile.FileName==""){this.lb_info.Text="请选择文件!";}else{stringfilepath=FileUpload1.PostedFile.FileName;stringfilename=filepath.Substring(filepath.LastIndexOf("\")+1);//stringserverpath1=Server.MapPath("images/")+filename;stringserverpath2=Server.MapPath("images/")+System.DateTime.Now.ToString("yyy-MM-dd-hh-mm-ss")+Session.SessionID+filename;//FileUpload1.PostedFile.SaveAs(serverpath1);Response.Write(filepath);ImageThumbnailimg=newImageThumbnail(filepath);img.ReducedImage(200,200,serverpath2);//0.4表示缩小40%this.lb_info.Text="上传成功!";}}catch(Exceptionerror){this.lb_info.Text="上传发生错误!原因:"+error.ToString();}类代码:usingSystem;usingSystem.IO;usingSystem.Drawing;usingSystem.Drawing.Imaging;publicclassImageThumbnail{publicImageResourceImage;privateintImageWidth;privateintImageHeight;publicstringErrorMessage;publicImageThumbnail(stringImageFileName){ResourceImage=Image.FromFile(ImageFileName);ErrorMessage="";}publicboolThumbnailCallback(){returnfalse;}//方法1,按大小publicboolReducedImage(intWidth,intHeight,stringtargetFilePath){try{ImageReducedImage;Image.GetThumbnailImageAbortcallb=newImage.GetThumbnailImageAbort(ThumbnailCallback);ReducedImage=ResourceImage.GetThumbnailImage(Width,Height,callb,IntPtr.Zero);ReducedImage.Save(@targetFilePath,ImageFormat.Jpeg);ReducedImage.Dispose();returntrue;}catch(Exceptione){ErrorMessage=e.Message;returnfalse;}}//方法2,按百分比缩小60%Percent为0.6targetFilePath为目标路径publicboolReducedImage(doublePercent,stringtargetFilePath){try{ImageReducedImage;Image.GetThumbnailImageAbortcallb=newImage.GetThumbnailImageAbort(ThumbnailCallback);ImageWidth=Convert.ToInt32(ResourceImage.Width*Percent);ImageHeight=(ResourceImage.Height)*ImageWidth/ResourceImage.Width;//等比例缩放ReducedImage=ResourceImage.GetThumbnailImage(ImageWidth,ImageHeight,callb,IntPtr.Zero);ReducedImage.Save(@targetFilePath,ImageFormat.Jpeg);ReducedImage.Dispose();returntrue;}catch(Exceptione){ErrorMessage=e.Message;returnfalse;}}}错误信息:上传发生错误!原因:System.IO.FileNotFoundException:C:DocumentsandSettingsAdministrator桌面猫13.jpg在System.Drawing.Image.FromFile(Stringfilename,BooleanuseEmbeddedColorManagement)在System.Drawing.Image.FromFile(Stringfilename)在ImageThumbnail..ctor(StringImageFileName)位置e:wwwrootApp_CodeImageThumbnail.cs:行号15在admin_cus_manage_invete_edit.Button4_Click(Objectsender,EventArgse)位置e:wwwrootadmincus_manageinvete_edit.aspx.cs:行号197问高手怎么该~~~
解决方案六:
各位兄台,怎么设置路径呢?????
解决方案七:
估计是搞不清楚服务器和客户端的区别.服务器又怎能直接读写客户端的文件呢?本机测试都是同一个机器当然能成功.
解决方案八:
急盼怎么设置路径呢???在线等
解决方案九:
上传发生错误!原因:System.IO.FileNotFoundException:C:DocumentsandSettingsnew桌面肖像4.jpg在System.Drawing.Image.FromFile(Stringfilename,BooleanuseEmbeddedColorManagement)在System.Drawing.Image.FromFile(Stringfilename)在Regedit.ImageThumbnail..ctor(StringImageFileName)位置d:freehostlianght7924webRegedit.aspx.vb:行号171在Regedit.ButtonTJ_Click(Objectsender,EventArgse)位置d:freehostlianght7924webRegedit.aspx.vb:行号100
解决方案十:
HttpContext.Current.Server.MapPath(@"photo你的图片名")
解决方案十一:
System.IO.FileNotFoundException未找到文件路径错了核对下吧
解决方案十二:
只有是路径问题了饿
解决方案十三:
System.IO.FileNotFoundException:C:DocumentsandSettingsnew桌面肖像4.jpg从提示上来看好象是说文件没找到,不要把图片放到桌面上,放到c盘或D盘根目录下试一下。
解决方案十四:
我不是搞VB.Net的,但是我觉得你没必要忙着写路径来存。你可以先Response出你的路径看看是否正确再来做。在C#里用Stringserverpath1=Server.MapPath("~/photo/")+filename;
解决方案十五:
try{if(FileUpload1.PostedFile.FileName==""){this.lb_info.Text="请选择文件!";}else{stringfilepath=FileUpload1.PostedFile.FileName;//stringfilename=filepath.Substring(filepath.LastIndexOf("\")+1);stringfilename=filepath.Substring(filepath.LastIndexOf("\")+1);//stringserverpath1=Server.MapPath("images/")+filename;stringserverpath2=Server.MapPath("images/")+System.DateTime.Now.ToString("yyy-MM-dd-hh-mm-ss")+Session.SessionID+filename;FileUpload1.PostedFile.SaveAs(serverpath2);Response.Write(filepath);ImageThumbnailimg=newImageThumbnail(filepath);img.ReducedImage(200,200,serverpath2);//0.4表示缩小40%this.lb_info.Text="上传成功!";}}catch(Exceptionerror){this.lb_info.Text="上传发生错误!原因:"+error.ToString();}===========================楼主的这个地方好像多了一个空格,造成获取文件文件名字是错误。楼主可以看一下是不是这个问题。
解决方案:
不行就写成相对路径把,别写绝对路径了!
解决方案:
你放在C目录下的,是不是禁用了写入功能呢?