/// <summary> /// 上传保存Excel文件,返回保存物理路径 /// </summary> /// <param name="FileUpExcel"></param> /// <returns></returns> public static string Saveupexcel(FileUpload FileUpExcel) { if (FileUpExcel.HasFile) { string excelfile = FileUpExcel.PostedFile.FileName; string exceltype = WordProcess.getext(excelfile); string newexcel = "student" + DateTime.Now.Millisecond.ToString(); string excelpath = HttpContext.Current.Server.MapPath("~/UpExcel/").ToString(); if (exceltype.ToLower() == "xls") { if (!Directory.Exists(excelpath)) { Directory.CreateDirectory(excelpath); } string savepath = excelpath + newexcel + "." + exceltype; FileUpExcel.PostedFile.SaveAs(savepath); return(savepath); } else { return(""); } } else { return(""); } }
public static string DownLoadOut(string downfilename) { string str = ""; if (downfilename.EndsWith("/")) { string cururl = HttpContext.Current.Request.Url.ToString(); int cur = cururl.IndexOf("Plugins") - 1; string weburl = cururl.Substring(0, cur) + downfilename.Replace("~", "");// +"index.htm"; HttpContext.Current.Response.Redirect(weburl); str = weburl; } else { string ft = WordProcess.getext(downfilename); switch (ft) { case "rar": DownLoadrar(downfilename); break; case "swf": case "docx": case "pptx": case "xlsx": case "e": case "gif": DownLoadold(downfilename); break; default: DownLoadold(downfilename); //DownLoad(downfilename); 作品重新提交后无法下载,难道有缓存? break; } } return(str); }