From 7a2d709d935075bcdc48e0f3f0ae9f4641663b9f Mon Sep 17 00:00:00 2001
From: wanshenmean <cathay_xy@163.com>
Date: 星期二, 17 三月 2026 09:12:34 +0800
Subject: [PATCH] docs: add repository contributor guidelines

---
 Code/WCS/WIDESEAWCS_S7Simulator/WIDESEAWCS_S7Simulator.Core/Persistence/FilePersistenceService.cs |   36 ++++++++++--------------------------
 1 files changed, 10 insertions(+), 26 deletions(-)

diff --git a/Code/WCS/WIDESEAWCS_S7Simulator/WIDESEAWCS_S7Simulator.Core/Persistence/FilePersistenceService.cs b/Code/WCS/WIDESEAWCS_S7Simulator/WIDESEAWCS_S7Simulator.Core/Persistence/FilePersistenceService.cs
index 27002dd..5305272 100644
--- a/Code/WCS/WIDESEAWCS_S7Simulator/WIDESEAWCS_S7Simulator.Core/Persistence/FilePersistenceService.cs
+++ b/Code/WCS/WIDESEAWCS_S7Simulator/WIDESEAWCS_S7Simulator.Core/Persistence/FilePersistenceService.cs
@@ -44,7 +44,8 @@
         /// <param name="dataPath">鏁版嵁鐩綍璺緞</param>
         public FilePersistenceService(string dataPath = "Data")
         {
-            _dataPath = dataPath;
+            // 杞崲涓虹粷瀵硅矾寰勶紙鍩轰簬褰撳墠宸ヤ綔鐩綍锛�
+            _dataPath = Path.GetFullPath(dataPath);
 
             try
             {
@@ -339,36 +340,19 @@
         }
 
         /// <summary>
-        /// 鍘熷瓙鎬у啓鍏ユ枃浠讹紙浣跨敤涓存椂鏂囦欢+鏇挎崲妯″紡锛�
+        /// 鍐欏叆鏂囦欢锛堢洿鎺ュ啓鍏ワ紝绠�鍖栫増鏈級
         /// </summary>
         private async Task WriteFileAtomicAsync(string filePath, string content)
         {
-            var tempPath = filePath + ".tmp";
-
-            try
+            // 纭繚鐩爣鏂囦欢鐨勭埗鐩綍瀛樺湪
+            var directory = Path.GetDirectoryName(filePath);
+            if (!string.IsNullOrEmpty(directory) && !Directory.Exists(directory))
             {
-                // 鍐欏叆涓存椂鏂囦欢
-                await File.WriteAllTextAsync(tempPath, content, Encoding.UTF8);
+                Directory.CreateDirectory(directory);
+            }
 
-                // 鍘熷瓙鎬ф浛鎹㈢洰鏍囨枃浠�
-                File.Replace(tempPath, filePath, null);
-            }
-            catch
-            {
-                // 娓呯悊涓存椂鏂囦欢
-                if (File.Exists(tempPath))
-                {
-                    try
-                    {
-                        File.Delete(tempPath);
-                    }
-                    catch
-                    {
-                        // 蹇界暐娓呯悊澶辫触
-                    }
-                }
-                throw;
-            }
+            // 鐩存帴鍐欏叆鏂囦欢
+            await File.WriteAllTextAsync(filePath, content, Encoding.UTF8);
         }
 
         /// <summary>

--
Gitblit v1.9.3