以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  [求助]删除指定文件夹的文件  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=87356)

--  作者:zcgmxf
--  发布时间:2016/7/8 23:14:00
--  [求助]删除指定文件夹的文件

老师,如何删除两天前以 年 月 日 时 分 秒 命名的文件

如 d:\\20160706101010.bak 是否可以拆分成日期格式后比对?


--  作者:hui986
--  发布时间:2016/7/9 4:08:00
--  

Dim strFiles As String  = "d:\\20160706101010.bak "
Dim strdate As String = FileSys.GetName(strFiles)
Dim Filesdate As String   \'文件日期
Dim strToDay As String   \'今天
Dim Intday As String

Filesdate  = strdate.SubString(0,8)
strToDay = Format(Date.Today(), "yyyyMMdd")
Output.Show("文件日期与今天相差:"  & strToDay - Filesdate & "天")

 

‘进行判断并进行相应删除代码……………………


--  作者:zcgmxf
--  发布时间:2016/7/9 12:08:00
--  
谢谢!朋友相差的天数都好算,就是删除 用 年 月 日 时 分 秒 命名的文件怎么定义呢?
--  作者:Hyphen
--  发布时间:2016/7/9 12:16:00
--  
Dim strFiles As String  = "d:\\20160706101010.bak"
Dim strdate As String = FileSys.GetName(strFiles)
strdate = strdate.Replace(".bak","")
strdate = strdate.Insert(12,":").Insert(10,":").Insert(8 ," ").Insert( 6,"-").Insert( 4,"-")
Dim d As Date = cdate(strdate)
Output.Show(d)