diff --git a/Rs.DeweyTester/Controls/UFixture.cs b/Rs.DeweyTester/Controls/UFixture.cs index 3d0dfb4..2e85aaf 100644 --- a/Rs.DeweyTester/Controls/UFixture.cs +++ b/Rs.DeweyTester/Controls/UFixture.cs @@ -9,6 +9,7 @@ using System.Drawing; using System.IO; using System.Linq; using System.Text; +using System.Text.RegularExpressions; using System.Threading.Tasks; using System.Windows.Forms; @@ -49,21 +50,52 @@ namespace Rs.MotionPlat } else { + int fileIndex = 1; + string logFileName = ""; + string regstr = tf.Index+"_(\\d{0,10}).txt"; //打印日志 string logDir = $"d:\\log\\debug\\{DateTime.Now.ToString("yyyyMMdd")}"; if (!Directory.Exists(logDir)) { Directory.CreateDirectory(logDir); } - string logFileName = $"{logDir}\\{tf.Index}.txt"; + string[] files = Directory.GetFiles(logDir); + if(files!=null && files.Length>0) + { + foreach (string f in files) + { + string fname = System.IO.Path.GetFileName(f); + if(Regex.IsMatch(fname,regstr)) + { + Match mh = Regex.Match(fname, regstr); + int tempIndex = int.Parse(mh.Groups[1].Value); + if(tempIndex>fileIndex) + { + fileIndex= tempIndex; + } + } + } + } + logFileName = $"{logDir}\\{tf.Index}_{fileIndex}.txt"; + FileInfo fi = new FileInfo(logFileName); - if(fi.Exists && fi.Length<=1024 * 1024 *1) + if(fi.Exists && fi.Length<=1024 * 1024 * 5) { File.AppendAllText(logFileName, $"{msg}"); } else { - File.WriteAllText(logFileName, $"{msg}"); + if(fi.Exists) + { + logFileName = $"{logDir}\\{tf.Index}_{++fileIndex}.txt"; + //换名称 + File.WriteAllText(logFileName, $"{msg}"); + + } + else + { + File.WriteAllText(logFileName, $"{msg}"); + } } if (label5.BackColor != Color.Lime) { diff --git a/Rs.DeweyTester/Home.cs b/Rs.DeweyTester/Home.cs index 4bcdd55..ac3ac9e 100644 --- a/Rs.DeweyTester/Home.cs +++ b/Rs.DeweyTester/Home.cs @@ -700,6 +700,26 @@ namespace Rs.MotionPlat } + dirpath = "D:\\Log\\Debug"; + if (!Directory.Exists(dirpath)) + { + Directory.CreateDirectory(dirpath); + } + dirs = Directory.GetDirectories(dirpath); + foreach (var dir in dirs) + { + RemoveReadOnlyAttribute(dir); + DirectoryInfo di = new DirectoryInfo(dir); + //di.Attributes = FileAttributes.Normal & FileAttributes.Directory; + DateTime dtCreate = di.CreationTime; + if ((DateTime.Now - dtCreate).Days > 7) + { + di.Delete(true); + } + } + + + dirpath = "D://软件备份"; if (!Directory.Exists(dirpath)) { @@ -714,7 +734,6 @@ namespace Rs.MotionPlat DateTime dtCreate = di.CreationTime; if ((DateTime.Now - dtCreate).Days > 15) { - di.Delete(true); } } diff --git a/Rs.DeweyTester/Properties/AssemblyInfo.cs b/Rs.DeweyTester/Properties/AssemblyInfo.cs index 602708f..5cfef91 100644 --- a/Rs.DeweyTester/Properties/AssemblyInfo.cs +++ b/Rs.DeweyTester/Properties/AssemblyInfo.cs @@ -31,6 +31,6 @@ using System.Runtime.InteropServices; // //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值 //通过使用 "*",如下所示: - [assembly: AssemblyVersion("1.20.24.32")] + [assembly: AssemblyVersion("1.20.24.33")] //[assembly: AssemblyVersion("1.0.0.0")] //[assembly: AssemblyFileVersion("1.0.0.0")]