是否可以使用INNO脚本移动现有目录/文件? [英] Is it possible to move existing directories/files with an INNO script?

查看:68
本文介绍了是否可以使用INNO脚本移动现有目录/文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们最近有一个使用INNO脚本进行安装的应用程序经过了重大的重组.

We've recently had an application which installs using an INNO script undergo a significant restructuring.

不幸的是,应用程序需要某些文件才能在版本之间持久化.

Unfortunately the application requires certain files to persist from version to version.

更不幸的是,在重组过程中,这些文件的位置已更改.

Even more unfortunately, the location of these files has changed during this restructuring.

最不幸的是,现在我不得不制作一个INNO脚本片段,该片段将查看那些文件是否存在,并将它们从以前的位置移到新的位置.

Most unfortunately, it now falls to me to craft an INNO script fragment which will look to see if those files exist, and to move them from their former location to their new location.

是否可以通过INNO脚本检查文件是否存在(与INNO脚本本身无关),如果存在,则在安装之前/之后将其移动到新位置完成了吗?

Is it possible to have an INNO script check to see if files (which have nothing to do with the INNO script itself in any capacity) exist, and if they do, to move them to a new location before/after the install is completed?

我说这些文件与INNO脚本无关,因为它们是用户生成的内容.

I say that these files have nothing to do with the INNO script because they are user-generated content.

推荐答案

是的,有可能.下面的代码是复制和删除(而不是原始移动或重命名).

Yes, it is possible. The code below is a copy and delete (instead of a raw move or rename).

使用[Code]部分来实现此逻辑.

Use the [Code] section to implement this logic.

有关支持的功能 如何对开始安装进行反应:

procedure CurStepChanged(CurStep: TSetupStep);
begin

  case CurStep of
    ssInstall:
    begin
      { will be executed just before the actual installation starts }
    end; 

   ssPostInstall:
    begin
      { will be executed just after the actual installation finishes }
    end; 
  end;

end;

如何知道文件是否存在

if FileExists(FileName) then
begin
  { do something when the file exists }
end; 

复制文件(覆盖现有文件)

if not FileCopy(ExistingFileName, NewFileName: String, false) then
begin
  { handle copy error }
end;

删除文件

if not DeleteFile(FileName) then
begin
  { handle delete error }
end;

这篇关于是否可以使用INNO脚本移动现有目录/文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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