diff --git a/WIN10_WinISP_SrcCode_For_MOKA_20250416_1/WinISP/FormISP_MSI.cs b/WIN10_WinISP_SrcCode_For_MOKA_20250416_1/WinISP/FormISP_MSI.cs index e17f7b8..aacfc56 100644 --- a/WIN10_WinISP_SrcCode_For_MOKA_20250416_1/WinISP/FormISP_MSI.cs +++ b/WIN10_WinISP_SrcCode_For_MOKA_20250416_1/WinISP/FormISP_MSI.cs @@ -168,6 +168,7 @@ namespace WinISP } #endif TopMost = true; + btnAuto.Enabled = false; Connect(); _lastNumOfMonitors = _numberOfMonitors; Application.Idle += Application_Idle; @@ -486,6 +487,7 @@ namespace WinISP frmISP.WriteLog("btnLoadFile_Click exception: " + ex.GetType().Name + ": " + ex.Message, "debug"); MessageBox.Show(this, "加载文件失败: " + ex.GetType().Name + "\n" + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); SetStatusMsg("Could not read file from disk.", true); + btnAuto.Enabled = false; } if (_binFilePath == String.Empty) @@ -504,10 +506,12 @@ namespace WinISP { SetStatusMsg(verifyErr, true); SetStatusMsg("Please select a F/W file."); + btnAuto.Enabled = false; } else { SetStatusMsg("BIN loaded. Ready to upgrade."); + btnAuto.Enabled = true; } } } @@ -643,7 +647,7 @@ namespace WinISP //if (IsConnect) { //WriteLog("IsConnect = true", "debug"); - btnAuto.Enabled = true; + btnAuto.Enabled = !String.IsNullOrEmpty(_binFilePath); if (String.IsNullOrEmpty(_binFilePath)) SetStatusMsg("Please select a F/W file."); else @@ -1623,7 +1627,7 @@ namespace WinISP { // BIN has a version but monitor version is unreadable – treat as mismatch. frmISP.WriteLog("ValidateMonitorVsBin: effVer is empty, cannot verify FW version.", "debug"); - errMsg = "FWVersion not match" ; + errMsg = "FW Version not match." ; return false; } string normalizedMonVer = NormalizeFwVersionForCompare(effVer); @@ -1631,7 +1635,7 @@ namespace WinISP frmISP.WriteLog("ValidateMonitorVsBin: normalizedMonVer=" + normalizedMonVer + " normalizedBinVer=" + normalizedBinVer, "debug"); if (!string.Equals(normalizedMonVer, normalizedBinVer, StringComparison.OrdinalIgnoreCase)) { - errMsg = "FWVersion not match"; + errMsg = "FW Version not match."; return false; } } @@ -1692,6 +1696,7 @@ namespace WinISP if (!ValidateMonitorVsBin(out checkErr)) { SetStatusMsg(checkErr, true); + btnAuto.Enabled = false; return; } prbProgress.Maximum = flashSectorInfo.Count; @@ -1745,6 +1750,7 @@ namespace WinISP { SetStatusMsg(verifyErr, true); SetISPStatus(false); + btnAuto.Enabled = false; return; } @@ -2105,14 +2111,26 @@ namespace WinISP System.IO.Directory.CreateDirectory(resultFolder); string path = resultFolder + (fileName == "" ? "" : fileName + "_") + DateTime.Now.ToString("yyyy-MM-dd") + ".log"; - if (_logWriter == null || _logPath != path) + try { - if (_logWriter != null) { _logWriter.Flush(); _logWriter.Close(); } - _logPath = path; - _logWriter = new System.IO.StreamWriter(path, append: true); + if (_logWriter == null || _logPath != path) + { + if (_logWriter != null) + { + _logWriter.Flush(); + _logWriter.Close(); + } + _logPath = path; + var stream = new FileStream(path, FileMode.Append, FileAccess.Write, FileShare.ReadWrite); + _logWriter = new System.IO.StreamWriter(stream); + } + _logWriter.WriteLine(DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss.fff: ") + str); + _logWriter.Flush(); + } + catch (IOException) + { + // Ignore logging failures caused by file locks. } - _logWriter.WriteLine(DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss.fff: ") + str); - _logWriter.Flush(); } public static Byte[] InitBinaryFile(String filepath)