我有一个.exe我的工作场所的配置文件,您可以指定删除文件(特别是在我的测试中保留最后说的30天文件[日志和SQL很好])它甚至清除子文件夹。但是它按修改日期删除,所以带有一些旧数据的新文件夹会删除旧的遗留物。
Destination Target
x.x.x.x/x vgw-xxxxxx
将离开:
Folder1:
File: Modified:
File 1 2018/02/02
File 2 2010/05/06
File 3 2018/02/01
Folder 2:
File: Modified:
File 1 2011/12/30
File 2 2006/01/16
File 3 2018/02/02
有没有改变这个,所以它保留了最后30个文件夹和内容,删除了其他所有内容?
这是我所拥有的" cleaner" .exe.config文件的内容:
Folder1:
File: Modified:
File 1 2018/02/02
File 3 2018/02/01
Folder 2:
File: Modified:
File 3 2018/02/02
答案 0 :(得分:0)
只是为了解决这个问题,修改日期并不重要,只需要的文件就不用了。所以我在配置文件中添加了一些目录,让它松散。
示例:
<?xml version="2.0" encoding="utf-8"?> <configuration> <configSections> </configSections> <!-- Make sure that every new location has a name with an increasing number e.g clear 1 -->
<appSettings>
<add key="connstring" value="Data Source=localhost;user id = *****;password = *****;Initial Catalog =Database;" />
<add key="sqldays" value="180" />
<add key="LogLocation" value="C:\File\Logs\Cleaner\" />
<add key="clear" value="C:\Directory\Logs,90" />
<add key="clear2" value="C:\Directory\CSV\Backup,30 " />
<add key="clear3"value="C:\Directory1\CSV\Backup,30 " />
<add key="clear4" value="C:\Directory2\CSV\Backup,30 " />
<add key="fileExtensions" value=".txt,.csv,.log,.fmt,.hdr,.Log" />
<add key="ClientSettingsProvider.ServiceUri" value="" /> </appSettings> </configuration>