Skip to content

Commit 33f2e45

Browse files
committed
Fixed the bug that non-existing log folder will crash the app.
1 parent 8a3573a commit 33f2e45

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

OKEGui/OKEGui/Properties/AssemblyInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,4 @@
4747
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
4848
// 方法是按如下所示使用“*”: :
4949
// [assembly: AssemblyVersion("1.0.*")]
50-
[assembly: AssemblyVersion("6.4.*")]
50+
[assembly: AssemblyVersion("6.5.*")]

OKEGui/OKEGui/Utils/Initializer.cs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -150,11 +150,14 @@ public static bool ConfigLogger()
150150

151151
public static void ClearOldLogs()
152152
{
153-
Directory.GetFiles("log")
154-
.Select(f => new FileInfo(f))
155-
.Where(f => f.LastWriteTime < DateTime.Now.AddMonths(-3) || (f.LastWriteTime < DateTime.Now.AddDays(-7) && f.Length < 1024))
156-
.ToList()
157-
.ForEach(f => f.Delete());
153+
if (Directory.Exists("log"))
154+
{
155+
Directory.GetFiles("log")
156+
.Select(f => new FileInfo(f))
157+
.Where(f => f.LastWriteTime < DateTime.Now.AddMonths(-3) || (f.LastWriteTime < DateTime.Now.AddDays(-7) && f.Length < 1024))
158+
.ToList()
159+
.ForEach(f => f.Delete());
160+
}
158161
}
159162
}
160163
}

0 commit comments

Comments
 (0)