title: Inno Setup - Check if file exist in destination or else if doesn't abort the installation
body: <p>I need my installer to check if a file exists in the destination location, and if is not there, then the installation aborts. My project is a update patch, so I want the installer to avoid installing the update files if the main exe of the application is not in the destination.  How can I do this?</p>
  
  <p>Can someone give an example of code to check file version through the Windows registry?</p>
  
  <pre><code>[Files]
  Source C:\filename.exe; DestDir {app}; Flags: ignoreversion; BeforeInstall: CheckForFile;
  
  [code]
  
  procedure CheckForFile(): Boolean;
  begin
    if (FileExists('c:\somefile.exe')) then
    begin
      MsgBox('File exists, install continues', mbInformation, MB_OK);
      Result := True;
    end
    else
    begin
      MsgBox('File does not exist, install stops', mbCriticalError, MB_OK);
      Result := False;
    end;
  end;
  </code></pre>