我的代码是通过任务计划程序重命名文本,但是为什么要添加所有文本?有没有办法我可以重命名那些我们不重命名的那些
示例(应该是什么::)>
[Payment20200219 to Payment20200219.0700从[提现20200219到[提现20200219.0700]
然后,日志将创建另一个文本文件(这是我们服务器的日志)
[Payment20200219至Payment20200219.1400从[提现20200219到[提现20200219.1400]
string FolderPath = @"C:\For Rename"; DirectoryInfo di = new DirectoryInfo(FolderPath); var files = di.EnumerateFiles("*.txt") .Where(s => s.Name.Contains("WithdrawalConfirm") || s.Name.Contains("paymentpagecalls")).ToList(); var Currentfile1 = files[0].FullName; var Currentfile2 = files[1].FullName; //Parsing files var Newfile1 = Currentfile1.Substring(0, Currentfile1.Length - 3); var Newfile2 = Currentfile2.Substring(0, Currentfile2.Length - 3); // Append new date Newfile1 = Newfile1 + DateTime.Now.ToString("HHmm") + ".txt"; Newfile2 = Newfile2 + DateTime.Now.ToString("HHmm") + ".txt"; //Rename File.Move(Currentfile1, Newfile1); File.Move(Currentfile2, Newfile2);
但是因此发生的就是继续增加时间
我的代码是通过任务计划程序重命名文本,但是为什么要添加所有文本?有没有一种方法可以重命名那些我们不重命名的示例(应该是什么):Payment20200219 to Payment20200219 ....
它一次又一次地重命名,因为选择文件的标准并不排除重命名的文件。