C#技术百科
问问你的心你有没有信心 做事情要专一坚定,执着
using System; using System.Web; using System.Web.UI; using System.IO; namespace webdb.classes { /// /// UploadFile 的摘要说明。 /// public class UploadFile { public UploadFile() { // // TODO: 在此处添加构造函数逻辑 // } /// /// 无参数的上传文件 /// /// public string GetSqlFile() { string sqlfile=""; string path = HttpContext.Current.Request.PhysicalApplicationPath.ToString()+"/upload"; if(Directory.Exists(path)) { } else { Directory.CreateDirectory(path); } HttpFileCollection files = HttpContext.Current.Request.Files; if(files[0].FileName.ToString().Length>0) { string filename = files[0].FileName.ToString(); string datestr = DateTime.Now.ToString("yyyyMMddHmmss")+DateTime.Now.Millisecond; string ext = filename.Substring(filename.LastIndexOf(".")); files[0].SaveAs(path+"\\"+datestr+ext); sqlfile=datestr+ext; } else { } return sqlfile; } public string GetSqlFile(string dir) { string sqlfile=""; string path = HttpContext.Current.Request.PhysicalApplicationPath.ToString()+"/upload/"; path +="\\"+dir; if(Directory.Exists(path)) { } else { Directory.CreateDirectory(path); } HttpFileCollection files = HttpContext.Current.Request.Files; if(files[0].FileName.ToString().Length>0) { string filename = files[0].FileName.ToString(); string datestr = DateTime.Now.ToString("yyyyMMddHmmss")+DateTime.Now.Millisecond; string ext = filename.Substring(filename.LastIndexOf(".")); files[0].SaveAs(path+"/"+datestr+ext); sqlfile=datestr+ext; } else { } return sqlfile; } } }
posted on 2008-06-12 00:09  王德田  阅读(265)  评论(0编辑  收藏  举报