CrazyIter_Bin há 5 meses atrás
pai
commit
1046eaec45

+ 7 - 3
TEAMModelOS.Extension/IES.Exam/IES.ExamServer/Program.cs

@@ -58,14 +58,18 @@ namespace IES.ExamServer
             builder.Services.AddHttpClient();
             builder.Services.AddSignalR();
             builder.Services.AddHttpContextAccessor();
-           
+            //此处能在Linux及MacOS运行,
+            //Windows的路径是LocalApplicationData Path: C:\Users\john\AppData\Local
+            //Linux的路径是LocalApplicationData Path: /home/john/.local/share,
+            //MacOS 的路径LocalApplicationData Path: /Users/john/Library/Application Support
             string localAppDataPath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
-            string dbpath = $"{localAppDataPath}\\ExamServer\\LiteDB";
+            //string dbpath = $"{localAppDataPath}\\ExamServer\\LiteDB";
+            string dbpath = Path.Combine(localAppDataPath, "ExamServer", "LiteDB");
             if (!System.IO.Directory.Exists(dbpath))
             {
                 System.IO.Directory.CreateDirectory(dbpath);
             }
-            string liteDBPath = $"Filename={dbpath}\\data.db;Connection=shared";
+            string liteDBPath = $"Filename={dbpath}/data.db;Connection=shared";
 
             var connections_LiteDB = new List<LiteDBFactoryOptions>
             {