NET 上传 有进度条
来源:互联网 发布:unity3d assets 解包 编辑:程序博客网 时间:2024/06/16 18:26
Response.Write("<div id='mydiv' >");
Response.Write("_");
Response.Write("</div>");
Response.Write("<script>mydiv.innerText = '';</script>");
Response.Write("<script language=javascript>;");
Response.Write("var dots = 0;var dotmax = 10;function ShowWait()");
Response.Write("{var output; output = '正在压缩并上传文件';dots++;if(dots>=dotmax)dots=1;");
Response.Write("for(var x = 0;x < dots;x++){output += '·';}mydiv.innerText = output;}");
Response.Write("function StartShowWait(){mydiv.style.visibility = 'visible'; ");
Response.Write("window.setInterval('ShowWait()',1000);}");
Response.Write("function HideWait(){mydiv.style.visibility = 'hidden';");
Response.Write("window.clearInterval();}");
Response.Write("StartShowWait();</script>");
Response.Flush();
Thread.Sleep(1000);
Response.Write("<script>HideWait()</script>");
其中,最后一句Response.Write("<script>HideWait()</script>");为结束进度条的操作,即隐藏。使用时可将进程添加在此句代码之上,当进程执行完以后便结束进度条。
单击上传文件夹按钮时,开始出现进度条,当文件夹压缩并且上传成功后,进度条结束。
在TextBox中手动输入将要上传的文件夹路径及文件夹名称,单击“上传文件夹”按钮,代码如下:
/// <summary>
/// 上传文件夹
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Button1_Click(object sender, EventArgs e)
{
if (TextBox1.Text == "") //如果输入为空,则弹出提示
{
this.Response.Write("<script>alert('输入为空,请重新输入!')</script>");
}
else
{
//压缩文件夹
string zipPath = TextBox1.Text.Trim(); //获取将要压缩的路径(包括文件夹名)
string zipedPath = @"c:\temp"; //压缩文件夹的路径(包括压缩文件名)
Zip Zc = new Zip();
//加载进度条
Response.Write("<div id='mydiv' >");
Response.Write("_");
Response.Write("</div>");
Response.Write("<script>mydiv.innerText = '';</script>");
Response.Write("<script language=javascript>;");
Response.Write("var dots = 0;var dotmax = 10;function ShowWait()");
Response.Write("{var output; output = '正在压缩并上传文件';dots++;if(dots>=dotmax)dots=1;");
Response.Write("for(var x = 0;x < dots;x++){output += '·';}mydiv.innerText = output;}");
Response.Write("function StartShowWait(){mydiv.style.visibility = 'visible'; ");
Response.Write("window.setInterval('ShowWait()',1000);}");
Response.Write("function HideWait(){mydiv.style.visibility = 'hidden';");
Response.Write("window.clearInterval();}");
Response.Write("StartShowWait();</script>");
Response.Flush();
Thread.Sleep(1000);
//压缩文件夹并上传
//调用Zip类中的ZipDir方法,压缩文件夹并上传,
//zipPath为原文件夹路径及文件夹名,zipedPath为压缩后上传的压缩文件路径及文件夹名,6为压缩等级
//具体参见上一篇博客或访问http://www.cnblogs.com/zhzhx/archive/2013/04/14/3021077.html
Zc.ZipDir(zipPath, zipedPath, 6);
//结束进度条
Response.Write("<script>HideWait()</script>");
//显示压缩文件夹信息
this.Label1.Text = "<Br/>";
this.Label1.Text += "文件压缩并且上传成功!";
this.Label1.Text += "<Br/>";
this.Label1.Text += "<li>" + "原文件路径:" + zipPath;
this.Label1.Text += "<Br/>";
this.Label1.Text += "<li>" + "压缩上传后文件路径:" + zipedPath;
}
}
0 0
- NET 上传 有进度条
- Asp.net添加上传进度条
- .net 多文件上传 进度条
- 文件上传框架(有进度条)
- Jquery ajax 上传文件(有进度条)
- flash+asp.net上传文件,显示进度条
- ASP.NET带进度条多文件上传
- ASP.NET带进度条多文件上传
- asp.net单文件带进度条上传
- NeatUpload上传大文件有进度条,上传速度快
- 有进度条的java,action,servlet,jsp大文件上传
- [翻译]ASP.NET(C#) 中的文件上传进度条
- [翻译]ASP.NET(C#) 中的文件上传进度条
- 让asp.net默认的上传组件支持进度条反映
- asp.net默认的上传组件支持进度条反映
- 让asp.net默认的上传组件支持进度条反映
- Asp, Asp.Net 无组件上传, 进度条, 断点续传
- 让asp.net默认的上传组件支持进度条反映
- 希腊大小写字母
- maven 之pom.xml
- HTML和CSS中如何判断ie各版本浏览器
- 入门dos,哈哈,发一个定时关机
- 第一天用
- NET 上传 有进度条
- 前台调用后台返回json的事例
- Java几种常见的编码格式
- 黑马程序员-高新技术-反射
- lvs-nat模式同网段设置路由表
- (3)Hive 内建操作符与函数开发——深入浅出学Hive
- hibernate annotation 自关联(自联接)配置
- C#调用dll,dll中执行C#端的回调函数
- Java设计模式泛型化之迭代器模式