国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 編程設計 > 正文

如何在線查詢本地機的文件?

2020-06-19 13:51:00
字體:
來源:轉載
供稿:網友

<html>

<head>

<title>隨風起舞之文件查詢</title>
</head>

<body>
<p align="center" >
  <b><font face="
宋體" color="red" size="5">
 
星河影動之文件查詢系統</font></b>
</p>
<hr>
<form method="POST" action="search.asp">
  <p><font color="green">
請輸入要查詢的目錄文字:
  <input type="text" name="search_data" size="20">
  <input type="submit" value="
查詢" name="B1">
  <input type="reset" value="
重寫" name="B2"></font>
  </p>
</form>
<hr>
<p style="text-indent: 0; word-spacing: 0; line-height: 100%; margin: 0">
<font color="green">
查詢結果:</font></p>

<%
data=request.form("search_data")

' 得到要查詢的文件名稱所要包含的字符串.
p=search_folder(data,"http://yup.go.163.com","c:/")

' 調用函數查詢目標查詢目錄下的所有子目錄(所有子樹).
%>

<script language="vbscript" RUNAT=SERVER>
'
目錄檢索函數.
function search_folder(search_data,v_path,c_path)
  dim file_system,cur_folder,sub_folders,sub_files
  if not isempty(search_data) and len(search_data)>0 then

' 確定查詢字符串有效非空.
      set file_system=createobject("scripting.filesystemobject")

' 建立文件系統對象.
      set cur_folder=file_system.getfolder(c_path)

  ' 建立建立當前目錄對象.
      set sub_folders=cur_folder.subfolders

' 建立當前目錄的子目錄對象集合.
      for each each_sub_folder in sub_folders

  ' 對子目錄集合進行遍歷.
          if each_sub_folder.attributes=16 then

      ' 確定子目錄的屬性為普通子目錄.
          sub_v_path=v_path&"/"&each_sub_folder.name
          sub_c_path=c_path&"/"&each_sub_folder.name

      ' 得到當前的子虛擬絕對路徑與真實絕對路徑.
            p=search_file(search_data,sub_v_path,sub_c_path)

        ' 調用文件檢索函數對當前子目錄下的文件進行字符串匹配檢索.
            p=search_folder(search_data,sub_v_path,sub_c_path)

        ' 遞歸檢索當前子目錄的下一級目錄.
          end if
      next
      set each_sub_folder=nothing
      set sub_folders=nothing
      set cur_folder=nothing
      set file_system=nothing

  ' 清除服務器端對象.
  end if
  end function

function search_file(search_data,v_path,c_path)
  dim file_system,sub_files,sub_file_v_path,sub_out_v_path

' 文件匹配檢索函數.
  if not isempty(c_path) then

  ' 確認路徑不為空.

    set file_system=createobject("scripting.filesystemobject")
    set cur_folder=file_system.getfolder(c_path)
    set sub_files=cur_folder.files

' 建立檢索目錄下的文件對象集合.
    for each each_file in sub_files

' 遍歷文件對象集合.
        if instr(each_file.name,search_data)<>0 then

    ' 匹配字符串與文件名.
            sub_file_v_path=v_path&"/"&each_file.name

        ' 建立可用鏈接,輸出匹配文件.

            sub_out_v_path=Replace(sub_file_v_path," ","%20")

            ' 替換路徑及文件名中出現的空格.
            response.write("<p><a href=" & sub_out_v_path & _
                        ">"&sub_file_v_path&"</a>")
        end if
    next
    set sub_out_v_path=nothing
    set sub_file_v_path=nothing
    set each_file=nothing
    set sub_files=nothing
    set file_system=nothing
  end if
end function
</script>

<hr>
</body></html>

[1]

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 潢川县| 盐津县| 东乌珠穆沁旗| 广元市| 佛山市| 启东市| 汽车| 长乐市| 新干县| 开化县| 拉萨市| 应城市| 灵山县| 九龙城区| 宽甸| 荆门市| 南安市| 莱西市| 开化县| 彭水| 达尔| 年辖:市辖区| 寻乌县| 城市| 商丘市| 新营市| 阜南县| 古蔺县| 平山县| 建始县| 错那县| 榆社县| 淮南市| 昭平县| 娄底市| 宜州市| 航空| 铜陵市| 公安县| 商都县| 岗巴县|