自解压 Zip:使用 .exe 文件指定解压路径
我正在制定 C# Winforms 应用程序的部署计划,并希望使用自解压 .zip 文件来分发所有必需的文件。以下是 SFX 的文件结构:
Setup.exe
应用程序.exe
应用程序2.exe
自述文件.txt
Manual.pdf
用户运行 SFX 后,我希望 Setup.exe
控制并复制 app.exe
、app2.exe
>、readme.txt
和 manual.pdf
到位置 x
。它们复制到的路径将取决于用户从 Setup.exe
的 UI、系统属性等中所做的选择。
我将如何编写 Setup.exe
C#?
I'm working on a deployment plan for a C# Winforms application and would like to use a self-extracting .zip file to distribute all of the required files. Here is the file structure of the SFX:
Setup.exe
app.exe
app2.exe
readme.txt
manual.pdf
After the user runs the SFX, I want Setup.exe
to take control and copy app.exe
, app2.exe
, readme.txt
, and manual.pdf
to location x
. The path they are copied to will depend on choices the user makes from the UI of Setup.exe
, system properties, etc.
How would I go about writing Setup.exe
in C#?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
就我个人而言,我在使用 NSIS 作为设置工具方面获得了非常好的体验。它比 SFX 稍微复杂一些,但确实很好用,相当灵活且免费。
因此,我建议您不要用 C# 编写自己的 SFX(又名“重新发明轮子”),而应该使用经实际验证的现有内容。
当然,还有许多其他可用的安装程序。
Personally, I had very good experiences with using NSIS as a setup tool. It's a bit more than a SFX but really good to use, rather flexible and free-of-charge.
So I recommend that you do not write your own SFX in C# (aka "re-inventing the wheel") but rather use something existing that is real-world-proofen.
There are, of course, a lot of other installers available.
我同意,当已经有可用的安装程序时,不要浪费时间编写安装程序。如果您出于某种原因选择自己编写一个语言,我会鼓励您远离任何需要依赖项的语言(例如,C# 需要 .Net 运行时)。我建议使用 C 或 C++ 并使用
/ 打开静态链接MT
标志 以便您的安装程序尽可能少地依赖。我使用过的一些安装软件(按优先顺序排列):
Nullsoft 脚本化安装系统(NSIS) - 这是一个免费的脚本安装程序,拥有庞大的用户群,包括 Firefox、DOSBox、7-Zip、Winamp 甚至 Dropbox。
Inno Setup - 这是免费的,并且项目文件的设置更像是 INI 文件。总体而言,非常易于使用,但功能不如 NSIS 丰富。有一个名为 ISTool 的可视化编辑器,它使它更易于使用。
Visual Studio 安装程序 / Microsoft Windows Installer - 它附带 Visual Studio,并且运行良好。它创建一个 MSI 安装包。
有关其他选项,请参阅 Wikipedia 上的安装软件列表文章。
I agree, don't waste your time writing an installer when there are already ones available. If you did chose to write one on your own for whatever reason, I would encourage you to stay away from any languages that require dependencies (e.g. C# requires the .Net Runtime). I would suggest using C or C++ and turning on static linking using the
/MT
flag so that your installer is dependent on as little as possible.Some of the installation software I've used (in order of preference):
Nullsoft Scriptable Install System (NSIS) - This is a free scripted installer which has a large user base including Firefox, DOSBox, 7-Zip, Winamp, and even Dropbox.
Inno Setup - This one is free, and the project files are setup more like an INI file. Overall, very easy to work with, but not as feature rich as NSIS. There is a visual editor called ISTool which makes it even easier to work with.
Visual Studio Installer / Microsoft Windows Installer - It comes with Visual Studio, and it works well enough. It creates a MSI setup package.
See the list of installation software article on Wikipedia for other options.