vs2005如何制作自解压软件

luc_ne 2008-06-10 06:49:17
想实现那种像winrar制作的自解压exe文件那样
可以在没有winrar的环境下运行
运行时将压缩包解压,解压完毕可以自动运行某个文件。

现在用vb.net实现了解压和运行的功能,但bin\debug下是一堆
data\xxx.zip,xxx.exe,xxx.config的文件,能否把它们搞成一个exe文件,运行起来和运行xxx.exe一样的效果

希望大家谈谈自己的看法
...全文
329 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
豆丁_ 2008-06-16
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 Jade_2008 的回复:]
没做过
帮顶啊..
[/Quote]
j147933783 2008-06-16
  • 打赏
  • 举报
回复
学习中~~~
帮顶!!!!!
ericzhangbo1982111 2008-06-16
  • 打赏
  • 举报
回复
可以自己写一个解压缩的类
解压算法网上有公开的
如果你不想很头疼的话
就用SharpZipLib.dll
这个很方便

把你要解压的文件放到你说的xx.exe中就可以了

using System;
using System.IO;

using ICSharpCode.SharpZipLib.Zip;

class MainClass
{

public static void Main(string[] args)
{
// Perform some simple parameter checking. More could be done
// like checking the target file name is ok, disk space, and lots
// of other things, but for a demo this covers some obvious traps.
if ( args.Length < 2 ) {
Console.WriteLine("Usage: CreateZipFile Path ZipFile");
return;
}

if ( !Directory.Exists(args[0]) ) {
Console.WriteLine("Cannot find directory '{0}'", args[0]);
return;
}

try
{
// Depending on the directory this could be very large and would require more attention
// in a commercial package.
string[] filenames = Directory.GetFiles(args[0]);

// 'using' statements gaurantee the stream is closed properly which is a big source
// of problems otherwise. Its exception safe as well which is great.
using (ZipOutputStream s = new ZipOutputStream(File.Create(args[1]))) {

s.SetLevel(9); // 0 - store only to 9 - means best compression

byte[] buffer = new byte[4096];

foreach (string file in filenames) {

// Using GetFileName makes the result compatible with XP
// as the resulting path is not absolute.
ZipEntry entry = new ZipEntry(Path.GetFileName(file));

// Setup the entry data as required.

// Crc and size are handled by the library for seakable streams
// so no need to do them here.

// Could also use the last write time or similar for the file.
entry.DateTime = DateTime.Now;
s.PutNextEntry(entry);

using ( FileStream fs = File.OpenRead(file) ) {

// Using a fixed size buffer here makes no noticeable difference for output
// but keeps a lid on memory usage.
int sourceBytes;
do {
sourceBytes = fs.Read(buffer, 0, buffer.Length);
s.Write(buffer, 0, sourceBytes);
} while ( sourceBytes > 0 );
}
}

// Finish/Close arent needed strictly as the using statement does this automatically

// Finish is important to ensure trailing information for a Zip file is appended. Without this
// the created file would be invalid.
s.Finish();

// Close is important to wrap things up and unlock the file.
s.Close();
}
}
catch(Exception ex)
{
Console.WriteLine("Exception during processing {0}", ex);

// No need to rethrow the exception as for our purposes its handled.
}
}
}
wuhaiwuya 2008-06-16
  • 打赏
  • 举报
回复
sharpzip 提供开源代码 很好用的
yilanwuyu123 2008-06-16
  • 打赏
  • 举报
回复
MARK
hyblusea 2008-06-15
  • 打赏
  • 举报
回复
我了解好像有一个算法对文件进行压缩和解压的
曲滨_銘龘鶽 2008-06-15
  • 打赏
  • 举报
回复
打一个包,把他放在 exe 文件后面
比如 exe 文件是 1000 字节
压缩包是 1000 字节
哪么最终就是 2000 字节

exe 文件后面设置一个起始为如 FF 00 FF CC XX
后面的就是压缩文件;

exe 运行后读取自己,找到 FF 00 FF CC XX 后
后面的就都是压缩包了,然后借用运行里面的东西

原理就是这样

或者用资源文件更简单一些(msdn上有列子)
Jade_2008 2008-06-12
  • 打赏
  • 举报
回复
没做过
帮顶啊..
myjce 2008-06-10
  • 打赏
  • 举报
回复
Gzip组件应该可以实现吧,没做过
小颖安装程序制作专家新一代的软件发布打包工具,内置BDE、MDAC、Microsoft SQL Server 2000 client数据库支持包, 支持数据压缩,生成的安装程序解压速度很快,内置超强的智能化管理引擎,你可以很轻松的管理 你要发布的软件。支持广告图显示,支持EXE/DLL/OCX自动注册,支持注册表操作,支持反安装,支 持多个地区语言(简、繁、英),支持加入软件序列号,生成的安装程序界面美观,共享版本没有任 何时间限制, 但不允许使用于商业应用目的。 如果你初次接触本软件,一时不知从何入手,请下 载Flash演示文档“如何创建一个简单的安装项目”学习如何使用本软件快速制作一个安装包! 发布版本:V5.33 发布日期:2005-2-20 1.修正了当开始菜单中“程序组名称”为空时,安装程序创建快捷方式会失败的问题; 有时,我们制作安装程序项目时可能只需要在桌面上创建快捷方式。 2.修正了读取注册表中字符串内容有可能不正确的问题。 发布版本:V5.34 发布日期:2005-3-13 1.修正了安装程序遇到只读类文件时操作失败等用户们反映的几个小BUG。 发布版本:V5.6 发布日期:2008-5-7 1.修正之前旧版本制作的安装包仍有些国产杀毒软件误报有木马的问题。 2.软件安装包数字签名兼容性改造。 3.VISTA系统兼容性修改。

111,120

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Creator Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧