现在的位置: 首页 >> 网站编程 >> ASP >> 将服务器端文件夹下的文件,按文件建立的时间先后排序
添加时间:2005-12-4 来源:网教中国 作者:
将服务器端文件夹下的文件,按文件建立的时间先后排序

  dir_name="abc"
  Set fso = CreateObject("Scripting.FileSystemObject")
  set self_path = fso.getfile(server.mappath(Request.ServerVariables("PATH_INFO")))
  files_path=self_path.ParentFolder.ParentFolder
  folderspec=files_path+"\"+dir_name
  Set f = fso.GetFolder(folderspec)
  
  Set fc = f.Files
  For Each f1 in fc
  response.write f1.name&"<br>"
  next
  ---------------------------------------------------------------
  
  <%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
  <%
  Function getFileInfo(filespec)'获取文件名和创建(修改)时间
  Dim fs, f
  dim s(1)
  Set fs = CreateObject("Scripting.FileSystemObject")
  Set f = fs.GetFile(filespec)
  s(0) = "文件名" & f.Name & "<br>创建时间: " & f.DateCreated & "<br>"
  s(1)=f.DateCreated
  getFileInfo=s
  End Function
  
  Sub compositor(s0,s1)'冒泡排序
  dim j,x
  j=0
  For i=0 to UBound(s1)
   For j=0 to UBound(s1)-j
   If Cint(Cdate(s1(i))-Cdate(s1(j)))>0 Then
   x=s1(i)
   s1(i)=s1(j)
   s1(j)=x
   x=s0(i)
   s0(i)=s0(j)
   s0(j)=x
   End If
   Next
  Next
  for i=0 to UBound(s0)
   response.Write(s0(i))
  next
  End Sub
  
  dir_name="abc"
  Set fso = CreateObject("Scripting.FileSystemObject")
  set self_path = fso.getfile(server.mappath(Request.ServerVariables("PATH_INFO")))
  files_path=self_path.ParentFolder.ParentFolder
  folderspec=files_path&"\"+dir_name
  Set f = fso.GetFolder(folderspec)
  
  Set fc = f.Files
  dim myFile(),fileCreateDate()
  i=0
  For Each f1 in fc
  redim preserve myFile(i)
   redim preserve fileCreateDate(i)
  myFile(i)=getFileInfo(files_path&"\"+dir_name&"\"&f1.name)(0)
  fileCreateDate(i)=cdate(getFileInfo(files_path&"\"+dir_name&"\"&f1.name)(1))
  i=i+1
  next
  compositor myFile,fileCreateDate
  %>
上一篇:存储过程入门 下一篇:ASP对excel的操作
大部分文章摘自网上,如有侵犯您的权益请与我们联系,我们会第一时间进行处理,谢谢! [ 打印文章 ] [ 关闭窗口 ]
推荐文章
·ASP下载系统防盗链方法
·尝尝ASP.NET中的小甜饼
·细细品味ASP.NET (四)
·ASP计数器设计详解-2
·升级MD5.ASP,打造完全动态不重
·用ASP设计网站在线人数统计程序
·ASP中使用SQL语句操作数据库
·ASP中函数调用对参数的影响
·Asp无组件文件上传的实例
·在ASP中使用SQL语句之2:用WHERE
相关文章
 
最新文章
·ASP下载系统防盗链方法
·ASP能读写注册表
·ASP 中健壮的页结构的异常处理
·在SQL Server中保存和输出图片
·使用ASP.NET加密口令
·web.config一个中文解释
·尝尝ASP.NET中的小甜饼
·用asp.net实现的把本文推荐给好
·开发BtoC电子商务系统(ASP.NET)
·保护 XML Web 服务免受黑客攻击
Google