.NET安装项目中删除制作安装文件夹上卸载文件夹、项目、NET

2023-09-07 00:30:48 作者:饕

我有一个.NET安装项目,安装和卸载我的应用程序正常,但在卸载它留下的安装目录。

I have a .NET setup project that installs and uninstalls my application fine but on uninstall it leaves the installation directory behind.

在卸载后在/我如何删除这个文件夹?

How can I delete this folder during/after the uninstall?

更新:我的应用程序运行时它看起来像夹在卸载过程中不会被删除的原因该目录中创建一个cahce文件

UPDATE: My application creates a cahce file in this directory when it runs which looks like the reason the folder is not removed during the uninstall.

有没有办法删除此文件,这样的文件夹被删除?

Is there a way to remove this file so that the folder gets removed?

推荐答案

通常安装过程中创建的文件夹将在卸载删除。

Normally the folder created during installation will be removed on uninstall.

然而,这并不发生,如果该文件夹不为空或其他进程已打开的句柄到该文件夹​​或在一个子文件夹。因此,你应该确保该文件夹不开的地方在资源管理器或控制台窗口中,你的应用程序没有运行,并且没有放置任何其他文件到该文件夹​​。

This does not happen however, if that folder is not empty or another process has an open handle to that folder or a subfolder within. Therefore you should make sure that the folder is not opened somewhere in Explorer or a console window, you application is not running and you didn't place any additional files to that folder.

您可以使用的Process Explorer 以打开的句柄查看使用查找 - >查找处理或DLL 的命令,并输入您的安装文件夹的名称

You can check with Process Explorer for open handles using the Find -> Find Handle or Dll command and entering the name of your installation folder.

您可以通过创建一个记录您的卸载获得更多的信息和可能的错误消息:

You can get extended information and possible error messages by creating a log of your uninstallation:

msiexec /x myProgram.msi /l*vx log.txt