日期:2014-05-17 浏览次数:20437 次
using System; using System.Data; using System.Configuration; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using System.Text; using System.IO; using System.Collections; public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void btnupfile_Click(object sender, EventArgs e) { string filename = fu.Value; Response.Write("<script type=\"text/javascript\">var sinfo=document.getElementById(\"sinfo\"); "); FileStream fsInput = new FileStream(filename, FileMode.Open, FileAccess.Read); StreamReader srInput = new StreamReader(fsInput); ArrayList arraylist = new ArrayList(); string srline; while ((srline = srInput.ReadLine()) != null) { arraylist.Add(srline); } srInput.Close(); //关闭文件,释放资源 fsInput.Close(); //文件写 string upfilepath = Server.MapPath("photo/") + Guid.NewGuid() + System.IO.Path.GetExtension(filename); FileStream fsOutput = new FileStream(upfilepath, FileMode.Create, FileAccess.Write); StreamWriter swOutput = new StreamWriter(fsOutput); int fisize = fu.MaxLength; for (int i = 0; i < arraylist.Count; i++) { Response.Write(" var val; val=\"文件大小:"+fisize+"K;\""); Response.Write(" val +=\"已上传: " + i * 1024 + "K;\""); Response.Write("sinfo.innerHTML=val;"); swOutput.WriteLi