1 ///
2 /// 清空文件夹
3 ///
4 /// 文件夹路径
5 /// 过期时间
6 private void removeTemporaryFiles(string filefullPath, int FileExpirationTime)
7 {
8 DirectoryInfo dir = new DirectoryInfo(filefullPath);
9 if (dir.Exists)
10 {
11 DirectoryInfo[] childs = dir.GetDirectories();
12 foreach (DirectoryInfo child in childs)
13 {
14 if (child.CreationTime < DateTime.Now.AddMinutes(-FileExpirationTime))
15 child.Delete(true);
16 }
17 }
18 //清空文件夹内zip压缩文件
19 foreach (string file in Directory.GetFiles(filefullPath, "*.zip"))
20 {
21 FileInfo fileInfo = new FileInfo(file);
22 if (fileInfo.CreationTime < DateTime.Now.AddMinutes(-FileExpirationTime))
23 {
24 fileInfo.Delete();
25 }
26 }
27
28
29 }