diff --git a/src/Configurations.cs b/src/Configurations.cs
index 21cf6e3..4c7d19b 100644
--- a/src/Configurations.cs
+++ b/src/Configurations.cs
@@ -4,16 +4,14 @@ namespace SeewoHelper
{
public static class Configurations
{
- private static readonly string _path = Path.Combine(Constants.BaseDirectory, "configs");
-
///
/// 配置
///
- public static readonly Configuration CoursewareSortingInfo = new Configuration(Path.Combine(_path, "CoursewareSortingInfo.json"), new CoursewareSortingInfo());
+ public static readonly Configuration CoursewareSortingInfo = new Configuration(Path.Combine(Constants.ConfigurationPath, "CoursewareSortingInfo.json"), new CoursewareSortingInfo());
///
/// 配置
///
- public static readonly Configuration UISettings = new Configuration(Path.Combine(_path, "UISettings.json"), new UISettings());
+ public static readonly Configuration UISettings = new Configuration(Path.Combine(Constants.ConfigurationPath, "UISettings.json"), new UISettings());
}
}
diff --git a/src/Constants.cs b/src/Constants.cs
index ee31315..3b1187d 100644
--- a/src/Constants.cs
+++ b/src/Constants.cs
@@ -1,4 +1,5 @@
using System;
+using System.IO;
using System.Reflection;
using System.Windows.Forms;
@@ -39,5 +40,15 @@ public static class Constants
/// 应用运行文件夹路径
///
public static readonly string BaseDirectory = Environment.CurrentDirectory;
+
+ ///
+ /// 日志路径
+ ///
+ public static readonly string LogPath = Path.Combine(BaseDirectory, "logs");
+
+ ///
+ /// 配置路径
+ ///
+ public static readonly string ConfigurationPath = Path.Combine(BaseDirectory, "configs");
}
}
diff --git a/src/Forms/WindowMain.Designer.cs b/src/Forms/WindowMain.Designer.cs
index 68291d8..1719ccc 100644
--- a/src/Forms/WindowMain.Designer.cs
+++ b/src/Forms/WindowMain.Designer.cs
@@ -329,6 +329,7 @@ private void InitializeComponent()
this.buttonCleanLog.Style = Sunny.UI.UIStyle.LightBlue;
this.buttonCleanLog.TabIndex = 3;
this.buttonCleanLog.Text = "清除Logs";
+ this.buttonCleanLog.Click += new System.EventHandler(this.ButtonCleanLog_Click);
//
// checkBoxAutoStart
//
diff --git a/src/Forms/WindowMain.cs b/src/Forms/WindowMain.cs
index 29935d0..d5558af 100644
--- a/src/Forms/WindowMain.cs
+++ b/src/Forms/WindowMain.cs
@@ -55,7 +55,7 @@ private async void ButtonStartCoursewareSorting_Click(object sender, EventArgs e
{
var path = textBoxCoursewareSortingSearchingPath.Text;
- if (IOUtilities.IsProperPath(path) && IOUtilities.GetPathType(path) == PathType.Directionary && Directory.Exists(path))
+ if (!string.IsNullOrWhiteSpace(path) && IOUtilities.IsProperPath(path) && IOUtilities.GetPathType(path) == PathType.Directionary && Directory.Exists(path))
{
var infos = listViewSubjectStorageInfos.Items.Cast().Select(x => (SubjectStorageInfo)x.Tag);
@@ -209,5 +209,13 @@ private void CheckBoxAutoStart_ValueChanged(object sender, bool value)
{
AutoStartUtilities.SetMeStart(checkBoxAutoStart.Checked);
}
+
+ private void ButtonCleanLog_Click(object sender, EventArgs e)
+ {
+ foreach (var file in Directory.GetFiles(Constants.LogPath).Where(x => x != Program.Logger.Path))
+ {
+ File.Delete(file);
+ }
+ }
}
-}
+}
\ No newline at end of file
diff --git a/src/Program.cs b/src/Program.cs
index 33cd2de..65a1305 100644
--- a/src/Program.cs
+++ b/src/Program.cs
@@ -9,7 +9,7 @@ namespace SeewoHelper
{
static class Program
{
- public static Logger Logger { get; } = new Logger(Path.Combine(Constants.BaseDirectory, "logs", DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss") + ".log"));
+ public static Logger Logger { get; } = new Logger(Path.Combine(Constants.LogPath, DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss") + ".log"));
public static FormStyleController FormStyleController { get; } = new FormStyleController();