实现asp.net的文件压缩、解压、下载
很早前就想做文件的解压、压缩、下载
了,不过一直没时间,现在项目做完了,今天弄了下。不过解压,压缩的方法还是看的网上的,嘻嘻~~不过我把它们综合了一下哦。呵呵~~
1.先要从网上下载一个icsharpcode.sharpziplib.dll
2.建立类AttachmentUnZip,内容如下:
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using ICSharpCode.SharpZipLib.Zip;
using ICSharpCode.SharpZipLib.GZip;
using ICSharpCode.SharpZipLib.BZip2;
using ICSharpCode.SharpZipLib.Checksums;
using ICSharpCode.SharpZipLib.Zip.Compression;
using ICSharpCode.SharpZipLib.Zip.Compression.Streams;
using System.IO;
/// <summary>
///AttachmentUnZip 的摘要说明
/// </summary>
public class AttachmentUnZip
{
public AttachmentUnZip()
{
//
//TODO: 在此处添加构造函数逻辑
//
}
public static void UpZip(string zipFile)
{
string[] FileProperties = new string[2];
FileProperties[0] = zipFile;//待解压的文件
FileProperties[1] = zipFile.Substring(0, zipFile.LastIndexOf("\\") + 1);//解压后放置的目标目录
UnZipClass UnZc = new UnZipClass();
UnZc.UnZip(FileProperties);
}
}
3.建立类UnZipClass,内容如下:
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.IO;
using IC
相关文档:
给页面的TextBox设置ReadOnly="True"时,在后台代码中不能赋值取值,下边几种方法可以避免:
1、不设置ReadOnly,设置onfocus=this.blur()
C#代码
<asp:TextBox ID="TextBox1" runat="server" onfocus=this.blur()></asp:TextBox>
<asp:TextBox ID="TextBox1" runat="serve ......
1. 生成aspnet的权限数据表和sp,使用.net 2.0的命令如下:
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727>aspnet_regsql -W
使用-W参数调出连接数据库向导,根据向导生成数据库数据。
2. 在web.config更改验证方式并添加providers
<configuration>
<connectionStrings>
<add name="dbConn ......
1.asp.net呼叫js
view
plain
copy
to clipboard
print
?
Response.Write("<mce:script language=javascript><!--
");
Response.Write("alert('欢迎您 ');"
);
Response.Write("location.href='login.aspx';"
)& ......
asp.net中此页的状态信息无效,可能已损坏的解决之道[转]
默认分类 2009-02-06 16:16:06 阅读137 评论0 字号:大中小
针对此问题网上有一种解决办法,就是在该工程中的web.config中添加如下代码: <pages enableEventValidation="False" viewStateEncryptionMode="Never" /> ,但也有很多加了这段语句后,还是出错 ......