解决方案 »
- 如何让当前显示时间动起来
- 谁会apache 里发布asp.net2.0的网站?
- repeater控件里动态生成的LinkButton无显示
- vs2008 是否支持Asp.Net Ajax客户端JavaScript智能提示功能?
- 数据库输出问题
- 如何实现:aspx的网页里有很多内容,访问时Page_Load里只让他输出Page_Load里Response.Write的内容,而不输出aspx的网页里的内容?
- 关于htc文件的使用问题,比平常多出了许多使用量
- RadioButtonList的Value不支持中文?
- 网页中要设置公文的一号字怎么办?
- 网页调试问题及正则表达式问题!
- 失败的一天,唉
- 数据库版本706产生错误,不知如何是好?
//选择文件
private void button1_Click(object sender, EventArgs e)
{
openFileDialog1.Filter = "压缩文件(*.gzip)|*.gzip";
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
textBox1.Text = openFileDialog1.FileName;
}
}
//解压文件
private void button2_Click(object sender, EventArgs e)
{ if (String.IsNullOrEmpty(textBox1.Text))
{
MessageBox.Show("请选择GZIP文件!", "信息提示");
return;
} if (String.IsNullOrEmpty(textBox2.Text))
{
MessageBox.Show("请输入解压文件名!", "信息提示");
return;
} string str1 = textBox1.Text;
string str2 = textBox2.Text.Trim();
byte[] myByte = null;
FileStream myStream = null;
FileStream myDesStream = null;
GZipStream myDeComStream = null;
try
{
myStream = new FileStream(str1, FileMode.Open);
myDeComStream = new GZipStream(myStream, CompressionMode.Decompress, true);
myByte = new byte[4];
int myPosition = (int)myStream.Length - 4;
myStream.Position = myPosition;
myStream.Read(myByte, 0, 4);
myStream.Position = 0;
int myLength = BitConverter.ToInt32(myByte, 0);
byte[] myData = new byte[myLength + 100];
int myOffset = 0;
int myTotal = 0;
while (true)
{
int myBytesRead = myDeComStream.Read(myData, myOffset, 100);
if (myBytesRead == 0)
break;
myOffset += myBytesRead;
myTotal += myBytesRead;
}
myDesStream = new FileStream(str2, FileMode.Create);
myDesStream.Write(myData, 0, myTotal);
myDesStream.Flush();
MessageBox.Show("解压文件完成!");
}
catch { }
finally
{
myStream.Close();
myDeComStream.Close();
myDesStream.Close();
}
}