那你就在pageload的时候获取日期嘛,然后判断是否存在,不存在就创建,上传的时候也就根据日期选择文件夹就OK了,
if (!Directory.Exists(imgpath))
Directory.CreateDirectory(imgpath);
if (!Directory.Exists(imgpath))
Directory.CreateDirectory(imgpath);
解决方案 »
- 如何用c#获取某网站的IP地址 如www.baidu.com的ip地址 在线等!
- :号与~冲充,怎么办?(急!急!)
- 在ASP.net中用C#怎么封装JS代码?
- win2003全文检索总是失败 提示“全文操作运行失败。查询子句只包含被忽略的词。”
- 请问,我要得到 DATAGRID中 CHECKBOX控件的值,怎么写代码,我已经写了个代码,但是无法实现,您来帮我看看
- 面试碰到的问题,不知所措,请高手做答!
- 关于在线播放
- 下面这个程序执行不了,请各位大虾帮忙
- 一个ASP程序员的转折!!!
- asp.net TreeView的问题! 救命!
- datalist循环出来的数据表格,我点击其中的一个表格打印,应该怎么做?
- 我是菜鸟,请大家帮帮我!急急急~~
{
string uploadName = FileUpload1.PostedFile.FileName;//获取待上传图片的完整路径,包括文件名
//string uploadName = InputFile.PostedFile.FileName;
string pictureName = ""; //上传后的图片名,以当前时间为文件名,确保文件名没有重复
int idx = uploadName.LastIndexOf(".");
string suffix = uploadName.Substring(idx); //获得上传的图片的后缀名
Random rand = new Random();
int c = rand.Next(1000, 9999);
pictureName = DateTime.Now.Ticks.ToString() + "_" + c + suffix;
string Files_Date = DateTime.Now.ToString("yyyyMMdd");
string path = Server.MapPath("image/" + Files_Date + "/");
//string path2 = Server.MapPath("~/image/small/" + Files_Date + "/");
if (!Directory.Exists(path)) Directory.CreateDirectory(path);
//if (!Directory.Exists(path2)) Directory.CreateDirectory(path2);
FileUpload1.PostedFile.SaveAs(path + pictureName);
string webpath = Server.MapPath("image/" + Files_Date + "/" + pictureName);
//string webpath2 = Server.MapPath("~/image/small/" + Files_Date + "/" + pictureName);
//MakeThumbnail(webpath, webpath2, 130, 130, "Cut");
//生成缩略图并存进文件夹 UserEntity ue = new UserEntity();
ue.RegistName = this.txt_regist.Text.Trim();
ue.RoleName = this.txt_role.Text.Trim();
ue.ServerName = this.txt_server.Text.Trim();
ue.PicPath = "image/" + Files_Date + "/" + pictureName;
bool result = new UserService().Addinfo(ue);
if (result)
Response.Write("<script>alert('提交成功');location='toupiao.aspx'</script>");
else
Response.Write("<script>alert('提交失败');</script>"); }
else
{
Response.Write("<script>alert('图片不能为空哦');location='javascript:history.go(-1);'</script>");
}