如何在Inno Setup中找到唯一的名称来重命名/存档旧目录 [英] How to find an unique name to rename/archive old directories in Inno Setup

查看:39
本文介绍了如何在Inno Setup中找到唯一的名称来重命名/存档旧目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每当我进行新安装时,我都会安装一个新目录.我在旧目录上安装时遇到问题,现在想存档旧目录.

Whenever I do a new install, I install a new directory. I am having issues with installing over old directories and would now like to archive my old directories.

如果 DirExists 返回true,我想将目录从 Directory 重命名为 DirectoryOld1 .

If DirExists returns true, I want to rename the directory from Directory to DirectoryOld1.

我遇到的问题是如何检查和遍历重命名过程,以便如果存在 DirectoryOld1 ,请将当前目录重命名为 DirectoryOld2 ,依此类推./p>

The issue I am having is how to check and iterate through the renaming process, so that if DirectoryOld1 exists, rename the current directory to DirectoryOld2 and so on.

推荐答案

如果我正确理解了您的问题,则希望将现有目录备份为唯一的(递增的)名称.对吧?

If I understand your question correctly, you want to backup an existing directory to a unique (incremented) name. Right?

这可以做到:

function BackupDir(OldName: string): Boolean;
var
  I: Integer;
begin
  I := 1;
  { Find a unique index }
  while DirExists(OldName + IntToStr(I)) do
  begin
    Inc(I);
  end;

  { And rename }
  Result := RenameFile(OldName, OldName + IntToStr(I)); 
end;

这篇关于如何在Inno Setup中找到唯一的名称来重命名/存档旧目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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