<html>xml:namespace prefix = o ns = “urn:schemas-microsoft-com:office:office” /??
<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]