private static bool BreakFileLocks(string path, bool force = true) { if (!PathEx.DirOrFileExists(path)) { return(true); } var doubleTap = false; Check: var locks = PathEx.GetLocks(path)?.ToArray(); if (locks?.Any() != true) { return(true); } if (doubleTap) { ProcessEx.Terminate(locks); return(true); } if (!force) { var lockData = locks.Select(p => $"ID: {p.Id:d5}; Name: '{p.ProcessName}.exe'").ToArray(); var information = string.Format(Language.GetText(lockData.Length == 1 ? nameof(en_US.FileLockMsg) : nameof(en_US.FileLocksMsg)), lockData.Join(Environment.NewLine)); if (MessageBoxEx.Show(information, Settings.Title, MessageBoxButtons.OKCancel, MessageBoxIcon.Information) != DialogResult.OK) { return(false); } } foreach (var process in locks) { if (process.ProcessName.EndsWithEx("64Portable", "Portable64", "Portable")) { continue; } ProcessEx.Close(process); } Thread.Sleep(400); doubleTap = true; goto Check; }