c# - Search and delete ten old files in specific folder based on file name? -


i'm administrator noname!! company has router. router creates log files (with @ least 500 mb of size each log) , sends them our ftp server.

the log file name this: noname-[2014-4-4]-03-1.log. can see date of create of log file in ftp server.

so write program delete ten old log files specific folder in ftp server have lsd-rmz name.

and program must run in ftp server.

how can search , find , delete ten old file lsd-rmz folder in c#?

directory.getfiles(path)          .where(x=>regex.ismatch(x,@"\w+\[\d+-\d+-\d+\]-\d+-\d+\.log"))          .orderby(x=>datetime.parse(regex.match(x,@"(?<=\[).*?(?=\])").value))          .take(10)          .tolist()          .foreach(x=>file.delete(x)); 

Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -