我想做一个上传,但他要求的就是上传RAR文件后,自动解压成文件夹或文件,这样可以吗.谢谢大家帮忙啊
解决方案 »
- GridView编辑状态同时有2个文件上传时出现问题
- 关于JS截取字符串 求大家指导
- C# Bulider下载
- 脚本事件
- 点击 确定 按钮,然后在按钮下面出现 确定中...请稍侯,这个一般是怎么做处理?
- netscape不支持showModalDialog(),怎么办?
- 如何在页面加载page_load时,弹出一个js对话框:欢迎光临!
- MVC的一个煎熬的问题,请大神入驻。
- datagrid问题,大家帮我看看
- 以下这段sql代码能不能只用一句sql语句实现?
- 求教 在datagrid中的单元格中点击,怎么实现调用播放器,试听音乐。
- 那位仁兄有ASP.NET 1.1入门经典——Visual C# .NET 2003编程篇的电子版的书?
ProcessStartInfo p = new ProcessStartInfo();
p.FileName = "winrar";
p.WindowStyle = ProcessWindowStyle.Normal ;
p.Arguments=" a -r 路径" + DateTime.Now.ToString("yyyyMMdd") + ".rar 路径";
Process proc =Process.Start(p);
就可以了。也许这个思路对你有帮助。
using System;
using System.Text;
using System.Collections;
using System.IO;
using System.Diagnostics;
using System.Runtime.Serialization.Formatters.Binary;
using System.Data;using ICSharpCode.SharpZipLib.BZip2;
using ICSharpCode.SharpZipLib.Zip;
using ICSharpCode.SharpZipLib.Zip.Compression;
using ICSharpCode.SharpZipLib.Zip.Compression.Streams;
using ICSharpCode.SharpZipLib.GZip;
namespace MyWinzip
{
/// <summary>
/// Class1 的摘要说明。
/// </summary>
public class UnZipClass
{
public void UnZip(string[] args)
{
ZipInputStream s = new ZipInputStream(File.OpenRead(args[0]));
ZipEntry theEntry;
while ((theEntry = s.GetNextEntry()) != null)
{
string directoryName = Path.GetDirectoryName(args[1]);
string fileName = Path.GetFileName(theEntry.Name);
//生成解压目录
Directory.CreateDirectory(directoryName);
if (fileName != String.Empty)
{
//解压文件到指定的目录
string path=args[1]+"\\"+theEntry.Name;
FileStream streamWriter = File.Create(path);
int size = 2048;
byte[] data = new byte[2048];
while (true)
{
size = s.Read(data, 0, data.Length);
if (size > 0)
{
streamWriter.Write(data, 0, size);
}
else
{
break;
}
}
streamWriter.Close();
}
}
s.Close();
}
}
}
this.openFileDialog1.ShowDialog();
string filename=this.openFileDialog1.FileName;//待解压的文件
int i=filename.LastIndexOf(".");
string filepath=filename.Substring(0,i)+"\\";//解压后放置的目标目录 string []FileProperties=new string[2];
FileProperties[0]=filename;
FileProperties[1]=filepath;
UnZipClass UnZc=new UnZipClass();
UnZc.UnZip(FileProperties);