解压过程后台运行(c#) 我现在做一个考试系统,遇到一个问题,做考试系统需要通过代码解压文件,但又不想让用户看到解压过程,就是想让解压过程后台运行,该怎么做?(C#)先谢谢各位了! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 ICSharpCode.SharpZipLib.dll File1.PostedFile.SaveAs(strPath);string []FileProperties=new string[2];FileProperties[0]=strPath; //待解压的文件FileProperties[1]=strPhotoPath+@"\";//解压后放置的目标目录UnZip(FileProperties);process 调用winrar解压 这个调用系统的rar ,传的参数看看rar文件夹下面的txt帮助文档。 使用 System.IO.Compression.GZipStream 类。或第三方的类,如:http://dotnetzip.codeplex.com 这个调用系统的rar ,传的参数看看rar文件夹下面的txt帮助文档。 actionbackgroudworkerbegininvoke http://topic.csdn.net/u/20101114/13/41a1869e-36ab-4467-97ee-e5e8d1e046f1.html tempDir = SharpZipLib(tempDir,m_inputFile.PostedFile.InputStream) //解压缩 private string SharpZipLib(string tempDir,Stream fileStream) { using (ZipInputStream s = new ZipInputStream(fileStream)) { string tempDirXLS = tempDir.Substring(0, tempDir.Length - 4); tempDirXLS = tempDirXLS + ".xls"; ZipEntry theEntry; while ((theEntry = s.GetNextEntry()) != null) { Console.WriteLine(theEntry.Name); string directoryName = Path.GetDirectoryName(theEntry.Name); string fileName = Path.GetFileName(theEntry.Name); // create directory if (directoryName.Length > 0) { Directory.CreateDirectory(directoryName); } if (fileName != String.Empty) { using (FileStream streamWriter = File.Create(tempDirXLS)) { 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; } } } } } //System.IO.File.Delete(tempDir); //解压缩成功后,删除zip文件 return tempDirXLS; }这是我以前作的 有人能帮俺解释一下下面这段代码吗? 字符串转成xml 在C#中检测到已经登录了的QQ账户不知如何实现 错误 1 非静态的字段、方法或属性“动物比赛.Form1.Cat.Shout()”要求对象引用 熟悉GPRS通信的请进!多谢! C# 如何做成Windows服务(急。。。。。) 2005下 Winform+access 就DataAdapter的update问题!!! 一个关于参数传递的问题! rdlc报表生成图片问题。 C#如何调用使用jks证书的Web服务? 请问Tag属性有什么用的啊? 求一个正则表达式
string []FileProperties=new string[2];
FileProperties[0]=strPath; //待解压的文件
FileProperties[1]=strPhotoPath+@"\";//解压后放置的目标目录
UnZip(FileProperties);
process 调用winrar解压
或第三方的类,如:http://dotnetzip.codeplex.com
backgroudworker
begininvoke
private string SharpZipLib(string tempDir,Stream fileStream)
{
using (ZipInputStream s = new ZipInputStream(fileStream))
{ string tempDirXLS = tempDir.Substring(0, tempDir.Length - 4);
tempDirXLS = tempDirXLS + ".xls"; ZipEntry theEntry;
while ((theEntry = s.GetNextEntry()) != null)
{ Console.WriteLine(theEntry.Name); string directoryName = Path.GetDirectoryName(theEntry.Name);
string fileName = Path.GetFileName(theEntry.Name); // create directory
if (directoryName.Length > 0)
{
Directory.CreateDirectory(directoryName);
} if (fileName != String.Empty)
{
using (FileStream streamWriter = File.Create(tempDirXLS))
{ 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;
}
}
}
}
} //System.IO.File.Delete(tempDir); //解压缩成功后,删除zip文件
return tempDirXLS; }
这是我以前作的