cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
SpiderLily1
Level 6

RenameFile to move folder to backup

This is driving me crazy, because I have other code in the same installer that works just fine when using RenameFile() to move folders and their contents (subfolders and files) to the backup folder.  For some reason, this code doesn't work, and I have no idea why.  I've tried creating the backup folder before the RenameFile() operation too, and the folder is created, but RenameFile() still doesn't work.  In the following code,  the messages for the "Base source path is " and "Base target path is " are displayed, and the paths are correct.  Then I just get the message "Could not move [folder2]  to  [folder2]" because RenameFile() failed.  Why?

 

 

 

 

//----------------------------
// Backup and restore Help 
//----------------------------
function BackupRestoreHelp(BackupDir)
	STRING SrcPath, TargetPath, HelpFiles;
begin
    Disable(LOGGING);
 
	if (!MAINTENANCE) then
		SrcPath = TARGETDIR;
		TargetPath = TARGETDIR ^ BackupDir;
	elseif (REMOVEONLY || REMOVEALL) then
		SrcPath = TARGETDIR ^ BackupDir;
		TargetPath = TARGETDIR;
	endif; 
 
   MessageBox("Base source path is " + SrcPath, INFORMATION);
   MessageBox("Base target path is " + TargetPath, INFORMATION);
	
	// Move the Help files
	HelpFiles = "help\\AppHelp";
	if (RenameFile(SrcPath ^ HelpFiles, TargetPath ^ HelpFiles) < 0) then
		MessageBox("Could not move " + 	SrcPath ^ HelpFiles + " to " + TargetPath ^ HelpFiles, SEVERE);
		abort;
	endif;	
	
  Enable(LOGGING);
end; 

 

 

 

 

Labels (1)
0 Kudos
(1) Reply
SpiderLily1
Level 6

To clarify, in the message "Could not move [folder2] to [folder2]", those paths are also correct.
0 Kudos