⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lx10_1.asp

📁 ASP 网页数据库短训教程源码
💻 ASP
字号:
<SCRIPT LANGUAGE=vbscript>
  Sub init()										' 这是Window对象的onload事件
    frm1.af.selectedIndex=frm1.h1.value					'   所调用的Sub过程,过程设置
    frm1.af.Focus									'   文件夹列表框选中项序号,并
  End Sub											'   为列表框设置焦点
</SCRIPT>
<SCRIPT FOR=af EVENT=onClick LANGUAGE=VBScript>	' 这是列表框的单击事件过程
  i=frm1.af.selectedIndex
  fm=frm1.af.options(i).text							' 取得选中项的文本,
  if left(fm,1)<>"[" then								' 如果选中项不是文件夹,则将列
    frm1.h1.value=I									' 表框选中项序号存入Hidden中
  end if
  frm1.submit										' 提交表单
</SCRIPT>
<HTML>
  <HEAD><TITLE>浏览文件属性</TITLE></HEAD>
  <body onload=init>									' Window对象的onload事件
    <form name=frm1 method=post>
    <TABLE BORDER=0 WIDTH=400>
<%
    Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
    Session("t1")=""									' 多行文本框内容清空
    Session("tn")=""									' 文件名变量清空
    Session("h1")=Request("h1")						' 保存提交的列表选中项序号
    if IsEmpty(Request("af")) and IsEmpty(Session("af")) then	' 若是打开网页
      set Session("af")=objFSO.GetFolder(Server.MapPath(".\"))	' 保存初始化的文件夹对象
    elseif not IsEmpty(Request("af")) then					' 若是提交了列表框选项
      if objFSO.FolderExists(Request("af")) then				'   若是文件夹,则保存文
        set Session("af")=objFSO.GetFolder(Request("af"))		'   件夹对象,而把列表选
        Session("h1")=0								'   中项序号清0
      else
        Set objFile = objFSO.GetFile(Request("af"))			'   否则,创建文件对象
        aline= aline & "文件的路径:" & objFile.Path & chr(13)
        aline= aline & "文件的建立日期:" & objFile.DateCreated & chr(13)
        aline= aline & "文件的大小:" & objFile.Size & chr(13)
        aline= aline & "文件的类型:" & objFile.Type & chr(13)
        Session("t1")=aline							' 将文件属性作为多行文本
        tn=objFSO.getfilename(Request("af"))				'   框内容,并保存文件名
        Session("tn")=tn
      end if
    end if
    Set objFolder = Session("af")						' 当前文件夹对象赋值
    Response.Write "<tr><td>当前目录:" & objFolder.Name
    Response.Write "<td>当前文件:" & Session("tn")
    ff=objFolder.parentfolder.path						' 取得父文件夹路径
    Response.Write "<tr><td><SELECT size =10 style='width:200px' name=af>"
    if trim(objFolder.parentfolder.Name)<>"" then
      Response.Write "<OPTION value="& ff & ">[..]"		' 列表框中父文件夹标志
    end if
    For Each objSubFolder in objFolder.SubFolders			' 列表框中的文件夹列表
      Response.Write "<OPTION value=" & objSubFolder.path & ">[" & objSubFolder.Name & "]"
    Next
    For Each objFile in objFolder.Files					' 列表框中的文件列表
      Response.Write "<OPTION value=" & objFile.path & ">" & objFile.Name
    Next
    Response.Write "</SELECT>"
    Response.Write "<td><TEXTAREA name=t1 rows=9 cols=45 wrap=off>"
    Response.Write Session("t1")						' 多行文本框中的文件属性列表
    Response.Write "</TEXTAREA>"
    Response.Write "</TABLE>"
    Response.Write "<INPUT type=Hidden name=h1 value=" & Session("h1") & ">"
    Set objFolder = Nothing
    Set objFSO = Nothing
%>
    </form>
  </BODY>
</HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -