title: How do I perform a move folder and delete operation using Innosetup [Windows Platform]
body: <p>I am a beginner in Pascal coding and Innosetup. Would like to request some advice on how to use the procedure to execute a delete folder and transfer folder operation.</p>
  
  <p>I was trying to move files from the release folder in 'C:\Program Files (x86)\winpxe1\Apache24\htdocs\current\Storygame*'
   to the current folder instead.
    'C:\Program Files (x86)\winpxe1\Apache24\htdocs\current\"
   Next, I wanted to delete another release folder of the same name in 'C:\Program Files (x86)\winpxe1\Apache24\Storygame'.</p>
  
  <p>The following is an extract of my code:</p>
  
  <pre><code>[Tasks]
  
  Name: "desktopicon";                                       Description: "{cm:CreateDesktopIcon}";GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked 
  
  [Files]
   Source: "C:\Program Files (x86)\Inno Setup 5\Examples\MyProg.exe";             
   DestDir: "{app}"; Flags: ignoreversion
  
  [Run] 
   Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,    {#StringChange(MyAppName, '&amp;', '&amp;&amp;')}}";AfterInstall: DirectoryCopy     DeleteTransferFolder Flags: nowait postinstall skipifsilent       
  
  [Code]
  
  procedure DirectoryCopy(SourcePath, DestPath: string);
  
    var
  
   FindRec: TFindRec;
   SourceFilePath: string;
   DestFilePath: string;
   begin
    if FindFirst(SourcePath + '\*', FindRec) then     
    begin     
     try      
      repeat       
    if (FindRec.Name &lt;&gt; '.') and (FindRec.Name &lt;&gt; '..')   then
       begin
           SourceFilePath := SourcePath + '\' + FindRec.Name;
  
            DestFilePath := DestPath + '\' + FindRec.Name;
  
              if FindRec.Attributes and FILE_ATTRIBUTE_DIRECTORY = 0 then
  
  
  begin
  
  if FileCopy(SourceFilePath, DestFilePath, False) then
  begin
             Log(Format('Copied %s to %s', [SourceFilePath, DestFilePath]));
           end
             else
           begin
             Log(Format('Failed to copy %s to %s', [SourceFilePath,          DestFilePath]));
           end;
         end
           else
         begin
           if DirExists(DestFilePath) or CreateDir(DestFilePath) then
           begin                                                                                    Log(Format('Created %s', [DestFilePath]));
             DirectoryCopy(SourceFilePath, DestFilePath);
           end
             else
           begin
             Log(Format('Failed to create %s', [DestFilePath]));
           end;
         end;
       end;
     until not FindNext(FindRec);
   finally
     FindClose(FindRec);
   end;
  end
    else
   begin
       Log(Format('Failed to list %s', [SourcePath]));
     end;
    end;
  
      procedure DirectoryCopy(SourcePath, DestPath: string);
      begin      
      Result := DirectoryCopy( 'C:\Program Files (x86)\winpxe1\Apache24      \htdocs\current\Storygame\*','C:\Program Files (x86)\winpxe1\Apache24\htdocs\current': string);                        
  end;
    procedure DeleteTransferFolder();
     begin
     MsgBox('DeleteTransferFolder 1', mbInformation, MB_OK);
  
     if (FileExists (ExpandConstant( 'C:\Program Files (x86)\winpxe1\Apache24    \Storygame'))) then
     begin      DelTree(ExpandConstant('C:\Program Files (x86)\winpxe1    \Apache24    \Storygame'), True, True, True);
  
     MsgBox('DeleteTransferFolder 2', mbInformation, MB_OK);    end;
  </code></pre>
  
  <p>After running this script, I encountered the "Compiler error": "Directive or Parameter "AfterInstall" expression error: Invalid token "DeleteTransferFolder" found."</p>
  
  <p>I would like to also give credit to the authors of the original code for the directorycopy and deletetransferfolder as it was extracted from other questions in this forum.
   Any advice appreciated on how I can integrate these codes with the existing support class references of innosetup. 
  Regards</p>