+ -
当前位置:首页 → 问答吧 → 第一题、第二题

第一题、第二题

时间:2008-10-08

来源:互联网

写一个函数,遍历一个文件夹下的文件及子文件夹中的文件:
[code]
<%
response.write F("tool")
Function F(folder)
Tpath=server.mappath(folder)
Set fso = Server.CreateObject("Scripting.FileSystemObject") '建立FSO对象
Set fd = fso.GetFolder(Tpath)

For each sfd In fd.SubFolders '子目录
  a=a&"文件夹:"&sfd&"<br />"
  For each f In sfd.Files '子目录文件
  s=f.path
  s=replace(s,tpath&"\","")

  a=a&"文件:"&s&"<br />"

  Next
Next
  
For each f In fd.Files'当前文件夹下的文件
  
  s=f.path
  s=replace(s,Tpath&"\","")
fileext=lcase(right(s,len(s)-InStrRev(s,".")))
a=a&name&s&"<br />"
Next
Set fso = nothing
Set fd = nothing
F=a
End Function
%>[/code]


写一个函数,对日期进行加减操作:
[code]
<%Response.write date_add("2008-09-10",100)
Response.write date_add("2008-09-10",-100)
Function date_add(times,days)

date_add=DateAdd("d", days,times)
End Function
%>[/code]
输出:2008-12-19
2008-6-2

作者: kuhanzhu   发布时间: 2008-10-08

恩,我好像被自己雷到了。

PHP等下写。

作者: kuhanzhu   发布时间: 2008-10-08


PHP的不写了,看了其他几位的代码,发现除了思路(或者说大致代码)一样外,更多的是班门弄斧。

作者: kuhanzhu   发布时间: 2008-10-08