protected void BtnUpDown_Click(object sender, EventArgs e)
{
if (FileUpload1.PostedFile.FileName != "")
{
//定义上传路径(在当前目录下的uploadfile文件下)
string uploadpath = this.Server.MapPath("../picture");
//取得文件名
string tmpfilename = FileUpload1.PostedFile.FileName;
//文件名
filename = tmpfilename.Substring(tmpfilename.LastIndexOf("\\") + 1);
//原文件的保存路径
string fileSavePath = uploadpath + "\\" + filename;
//保存原图片
FileUpload1.SaveAs(fileSavePath);
//调用生成缩略图程序,生成缩略图及生成写字的图片
this.toImage(FileUpload1.PostedFile.InputStream, uploadpath, filename);
//求取后缀名
string suffix = filename.Substring(filename.LastIndexOf("."));
//显示图片
//分别为原图片/写字的图片(多一个w)/缩略图(多一个x)
this.Image1.ImageUrl = "~/picture/" + filename;
this.Image2.ImageUrl = "~/picture/" + filename.Replace(suffix, "w" + suffix);
this.Image3.ImageUrl = "~/picture/" + filename.Replace(suffix, "x" + suffix);
//显示图像控件
this.Image1.Visible = true;
this.Image2.Visible = true;
this.Image3.Visible = true;
}
else
{
Response.Write("<script>alert('上传的文件不能为空!');loaction='pic.aspx'</script>");
}
}
这段程序调试时出错:“/”应用程序中的服务器错误。
--------------------------------------------------------------------------------未能找到路径“F:\03\PlayVideo\picture\4.jpg”的一部分。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.IO.DirectoryNotFoundException: 未能找到路径“F:\03\PlayVideo\picture\4.jpg”的一部分。源错误:
行 145: string fileSavePath = uploadpath + "\\" + filename;
行 146: //保存原图片
行 147: FileUpload1.SaveAs(fileSavePath);
行 148: //调用生成缩略图程序,生成缩略图及生成写字的图片
行 149: this.toImage(FileUpload1.PostedFile.InputStream, uploadpath, filename);
{
if (FileUpload1.PostedFile.FileName != "")
{
//定义上传路径(在当前目录下的uploadfile文件下)
string uploadpath = this.Server.MapPath("../picture");
//取得文件名
string tmpfilename = FileUpload1.PostedFile.FileName;
//文件名
filename = tmpfilename.Substring(tmpfilename.LastIndexOf("\\") + 1);
//原文件的保存路径
string fileSavePath = uploadpath + "\\" + filename;
//保存原图片
FileUpload1.SaveAs(fileSavePath);
//调用生成缩略图程序,生成缩略图及生成写字的图片
this.toImage(FileUpload1.PostedFile.InputStream, uploadpath, filename);
//求取后缀名
string suffix = filename.Substring(filename.LastIndexOf("."));
//显示图片
//分别为原图片/写字的图片(多一个w)/缩略图(多一个x)
this.Image1.ImageUrl = "~/picture/" + filename;
this.Image2.ImageUrl = "~/picture/" + filename.Replace(suffix, "w" + suffix);
this.Image3.ImageUrl = "~/picture/" + filename.Replace(suffix, "x" + suffix);
//显示图像控件
this.Image1.Visible = true;
this.Image2.Visible = true;
this.Image3.Visible = true;
}
else
{
Response.Write("<script>alert('上传的文件不能为空!');loaction='pic.aspx'</script>");
}
}
这段程序调试时出错:“/”应用程序中的服务器错误。
--------------------------------------------------------------------------------未能找到路径“F:\03\PlayVideo\picture\4.jpg”的一部分。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.IO.DirectoryNotFoundException: 未能找到路径“F:\03\PlayVideo\picture\4.jpg”的一部分。源错误:
行 145: string fileSavePath = uploadpath + "\\" + filename;
行 146: //保存原图片
行 147: FileUpload1.SaveAs(fileSavePath);
行 148: //调用生成缩略图程序,生成缩略图及生成写字的图片
行 149: this.toImage(FileUpload1.PostedFile.InputStream, uploadpath, filename);
解决方案 »
- C#定义的函数在asp.NET 的前端文件中如何调用?
- 单位要开始做一个自用的CMS系统,怎么制订开发流程.
- 提示: 超时时间已到。在从池中获取连接之前超时时间已过。出现这种情况可能是因为所有池连接都已被使用并已达到最大池大小
- 【新手问题】三层结构,UI层如何显示DAL的错误信息?
- 求高手来看看续传问题
- 怎么实现按不同的内容搜索啊
- System.Text.UnicodeEncoding 急!!!!!!!!!!!!
- 200分征求问题的答案 是关于任意文件在数据库中的存入和取出,孟子大哥各位高手请进
- DataGrid(一)
- 在datagrid中添加数据!
- 求助上传图片以二进制方式上传与读取的问题
- asp.net数据库查询问题
你看看你机器上这个路径全不全,一层层的文件夹必需存在,它不会自己创建文件夹
特别是站点根目录的picture文件夹,特别注意