Im trying to implement an update function for my app.
Everything is working except the second app that is installing the update ( copy the new to the old file) that fails because its uses by another process. Does anybody know how i can solve this problem ? Regards
Main Application Code
    private void _installTimer_Tick(object sender, EventArgs e) {
                installCount++;
                lblDownloadStatus.Content = "Update wird installiert...";
                if (installCount == 3) {
                    lblDownloadedSize.Visibility = Visibility.Collapsed;
                    progressBarUpdate.Visibility = Visibility.Collapsed;
                    progressBarInstall.Visibility = Visibility.Visible;
// starts the update Application
                    var inWatchUpdater = AppDomain.CurrentDomain.BaseDirectory + "inWatchUpdater.exe";
                    if (File.Exists(inWatchUpdater)) {
                        Process.Start(inWatchUpdater);
                        Application.Current.Shutdown();
                    }
                    else {
                        MessageBox.Show("cant find file");
                    } 
                }
            }
Update Application Code:
  static string _inWatchTempFile = Path.Combine(Environment.GetFolderPath(
                    Environment.SpecialFolder.ApplicationData) + "\\inWatch\\update\\inWatchUpdateTemp.exe");
                static string _inWatchCurrent = AppDomain.CurrentDomain.BaseDirectory + "InWatch.exe";
    static void updateApplication() {
    if(File.Exists(_inWatchTempFile) && 
        File.Exists(_inWatchCurrent)) {
        File.Copy(_inWatchTempFile, _inWatchCurrent, true);
        if (File.Exists(_inWatchCurrent)) {
            Process.Start(_inWatchCurrent);
        }
    }
    else {
        Console.WriteLine("Files doesnt exist");
    }
}
