如果文件存在,则 Visual Studio 安装项目有条件 [英] Visual Studio Setup Project conditional if File Exists

查看:116
本文介绍了如果文件存在,则 Visual Studio 安装项目有条件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序有一个安装/部署项目,它将某些文件(*.dll、*.dat)输出到应用程序文件夹.

I have a Setup/Deployment Project for my Application and it outputs certain files (*.dll, *.dat) to the Application Folder.

我想设置一个条件来检查文件当前是否存在.如果没有,请编写它,但如果有,请不要从包中安装它.可能吗?

I would like a condition to be set to check if a file currently exists or not. If it doesn't, write it but if it does, don't install it from the package. Is it possible?

该文件名为database.dat",在属性"下,我看到一个条件"属性,但我不知道该放什么.

The file is called "database.dat" and under the Properties, I see a "Condition" attribute, but I'm not familiar with what to put in there.

非常感谢任何输入.提前致谢.

Any input is greatly appreciated. Thanks in advance.

它已经存在的原因是,在之前的安装中,我们不想覆盖数据集/数据表中的数据.

Reason why it would already exist is that from a previous install there would be data from a DataSet / Data Table which we don't want to overwrite.

推荐答案

要只安装一个文件,如果它不存在,请按照下列步骤操作:

To only install a file, if it doesn't already exist, follow these steps:

  1. 在设置项目的启动条件"视图下添加搜索目标机器"条目.

  1. Add a "Search Target Machine" entry under the "Launch Conditions" view in your setup project.

填写FileName 属性和Folder 属性.

仅此而已.

来源(因为我只需要自己解决这个问题):

Sources (since I just had to figure this out for myself):

这篇关于如果文件存在,则 Visual Studio 安装项目有条件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆