Asp.net源码专业站
预留广告位
首页->门户综合->逐迹内容管理系统AspxNuke v2.0源码>>Common/Library/Web/UploadHelper.cs>>源码在线查看
温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:逐迹内容管理系统AspxNuke v2.0源码
当前文件:文件类型 AspxNuke/Common/Library/Web/UploadHelper.cs[2K,2009-6-12 11:32:25]打开代码结构图
普通视图
		            
1using System; 2using System.IO; 3using System.Web; 4using System.Web.UI.WebControls; 5using AspxNuke.Library.Globalization; 6 7namespace AspxNuke.Library.Web 8{ 9 /// <summary> 10 /// 上传帮助类 11 /// </summary> 12 public class UploadHelper 13 { 14 private string _filePath = ConfigHelper.FilePath; 15 private int _fileSize = ConfigHelper.FileSize; 16 17 private string _message = string.Empty; 18 19 /// <summary> 20 /// 反馈消息 21 /// </summary> 22 public string Message 23 { 24 set { _message = value; } 25 get { return _message; } 26 } 27 28 /// <summary> 29 /// 上传文件 30 /// </summary> 31 /// <param name="fileUpload">上传控件</param> 32 /// <param name="upPath">上传目录</param> 33 public void SaveAs(FileUpload fileUpload, out string upPath) 34 { 35 if (fileUpload == null) 36 { 37 throw new ArgumentNullException("fileUpload"); 38 } 39 40 upPath = string.Empty; 41 42 try 43 { 44 int size = fileUpload.PostedFile.ContentLength; 45 46 //判断文件大小 47 if (size > _fileSize) 48 { 49 _message = "文件太大,不能上传!"; 50 } 51 else 52 { 53 upPath = _filePath + DateTime.Now.ToShortDateString(); 54 //判断目录是否存在,不存在创建目录 55 if (!Directory.Exists(HttpContext.Current.Server.MapPath(upPath))) 56 { 57 Directory.CreateDirectory(HttpContext.Current.Server.MapPath(upPath)); 58 } 59 string filename = string.Concat(upPath, @"/", fileUpload.FileName); 60 61 upPath = filename; 62 63 //上传文件 64 fileUpload.SaveAs(HttpContext.Current.Server.MapPath(filename)); 65 } 66 } 67 catch (Exception ex) 68 { 69 _message = "文件上传失败:" + ex.Message; 70 throw; 71 } 72 } 73 } 74}
还没有找到您心仪的内容?请用.net源码大搜捕
代码片断 打包下载该项目完整源码:逐迹内容管理系统AspxNuke v2.0源码
51Aspx.com 版权所有 CopyRight © 2006-2010. 京ICP备06046876号 本站法律顾问:ITlaw-庄毅雄律师
返回顶部
客户服务:点击这里进行客户咨询 业务合作:点击这里洽谈业务合作 合作热线:010-68880146