欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

如何在线查询本地机的文件?

程序员文章站 2022-04-15 09:19:54
随风起舞之文件查询</title...</div> <div class="content"> <p class="msonormal" style="margin: 0cm 0cm 0pt"><span lang="en-us" style="font-family: ''; mso-bidi-font-size: 9.0pt"><html><?xml:namespace prefix="o" ns="urn:schemas-microsoft-com:office:office"?><p></p></span></p> <p class="msonormal" style="margin: 0cm 0cm 0pt"><span lang="en-us" style="font-family: ''; mso-bidi-font-size: 9.0pt"><head><p></p></span></p> <p class="msonormal" style="margin: 0cm 0cm 0pt"><span lang="en-us" style="font-family: ''; mso-bidi-font-size: 9.0pt"><title></span><span style="font-family: 宋体; mso-ascii-font-family: ''; mso-hansi-font-family: ''; mso-bidi-font-size: 9.0pt">随风起舞之文件查询</span><span lang="en-us" style="font-family: ''; mso-bidi-font-size: 9.0pt"></title><br></head><p></p></span></p> <p class="msonormal" style="margin: 0cm 0cm 0pt"><span lang="en-us" style="font-family: ''; mso-bidi-font-size: 9.0pt"><body><br><p align="center" ><br>  <b><font face="</span><span style="font-family: 宋体; mso-ascii-font-family: ''; mso-hansi-font-family: ''; mso-bidi-font-size: 9.0pt">宋体</span><span lang="en-us" style="font-family: ''; mso-bidi-font-size: 9.0pt">" color="red" size="5"><br>  </span><span style="font-family: 宋体; mso-ascii-font-family: ''; mso-hansi-font-family: ''; mso-bidi-font-size: 9.0pt">星河影动之文件查询系统</span><span lang="en-us" style="font-family: ''; mso-bidi-font-size: 9.0pt"></font></b><br></p><br><hr><br><form method="post" action="search.asp"><br>  <p><font color="green"></span><span style="font-family: 宋体; mso-ascii-font-family: ''; mso-hansi-font-family: ''; mso-bidi-font-size: 9.0pt">请输入要查询的目录文字</span><span lang="en-us" style="font-family: ''; mso-bidi-font-size: 9.0pt">:<br>  <input type="text" name="search_data" size="20"><br>  <input type="submit" value="</span><span style="font-family: 宋体; mso-ascii-font-family: ''; mso-hansi-font-family: ''; mso-bidi-font-size: 9.0pt">查询</span><span lang="en-us" style="font-family: ''; mso-bidi-font-size: 9.0pt">" name="b1"><br>  <input type="reset" value="</span><span style="font-family: 宋体; mso-ascii-font-family: ''; mso-hansi-font-family: ''; mso-bidi-font-size: 9.0pt">重写</span><span lang="en-us" style="font-family: ''; mso-bidi-font-size: 9.0pt">" name="b2"></font><br>  </p><br></form><br><hr><br><p style="text-indent: 0; word-spacing: 0; line-height: 100%; margin: 0"><br><font color="green"></span><span style="font-family: 宋体; mso-ascii-font-family: ''; mso-hansi-font-family: ''; mso-bidi-font-size: 9.0pt">查询结果</span><span lang="en-us" style="font-family: ''; mso-bidi-font-size: 9.0pt">:</font></p><br><br><%<br>data=request.form("search_data")<p></p></span></p> <p class="msonormal" style="margin: 0cm 0cm 0pt"><span lang="en-us" style="font-family: ''; mso-bidi-font-size: 9.0pt">' </span><span style="font-family: 宋体; mso-ascii-font-family: ''; mso-hansi-font-family: ''; mso-bidi-font-size: 9.0pt">得到要查询的文件名称所要包含的字符串</span><span lang="en-us" style="font-family: ''; mso-bidi-font-size: 9.0pt">.<br>p=search_folder(data,"http://yup.go.163.com","c:\")<p></p></span></p> <p class="msonormal" style="margin: 0cm 0cm 0pt"><span lang="en-us" style="font-family: ''; mso-bidi-font-size: 9.0pt">' </span><span style="font-family: 宋体; mso-ascii-font-family: ''; mso-hansi-font-family: ''; mso-bidi-font-size: 9.0pt">调用函数查询目标查询目录下的所有子目录(所有子树)</span><span lang="en-us" style="font-family: ''; mso-bidi-font-size: 9.0pt">.<br>%><br><br><script language="vbscript" runat=server><br>' </span><span style="font-family: 宋体; mso-ascii-font-family: ''; mso-hansi-font-family: ''; mso-bidi-font-size: 9.0pt">目录检索函数</span><span lang="en-us" style="font-family: ''; mso-bidi-font-size: 9.0pt">.<br>function search_folder(search_data,v_path,c_path)<br>  dim file_system,cur_folder,sub_folders,sub_files<br>  if not isempty(search_data) and len(search_data)>0 then<p></p></span></p> <p class="msonormal" style="margin: 0cm 0cm 0pt; text-indent: 10.5pt; mso-char-indent-count: 1.0; mso-char-indent-size: 10.5pt"><span lang="en-us" style="font-family: ''; mso-bidi-font-size: 9.0pt">' </span><span style="font-family: 宋体; mso-ascii-font-family: ''; mso-hansi-font-family: ''; mso-bidi-font-size: 9.0pt">确定查询字符串有效非空</span><span lang="en-us" style="font-family: ''; mso-bidi-font-size: 9.0pt">.<br>      set file_system=createobject("scripting.filesystemobject")<p></p></span></p> <p class="msonormal" style="margin: 0cm 0cm 0pt; text-indent: 27pt; mso-char-indent-count: 2.57; mso-char-indent-size: 10.5pt"><span lang="en-us" style="font-family: ''; mso-bidi-font-size: 9.0pt">' </span><span style="font-family: 宋体; mso-ascii-font-family: ''; mso-hansi-font-family: ''; mso-bidi-font-size: 9.0pt">建立文件系统对象</span><span lang="en-us" style="font-family: ''; mso-bidi-font-size: 9.0pt">. <br>      set cur_folder=file_system.getfolder(c_path)<p></p></span></p> <p class="msonormal" style="margin: 0cm 0cm 0pt; text-indent: 16.5pt"><span lang="en-us" style="font-family: ''; mso-bidi-font-size: 9.0pt">  ' </span><span style="font-family: 宋体; mso-ascii-font-family: ''; mso-hansi-font-family: ''; mso-bidi-font-size: 9.0pt">建立建立当前目录对象</span><span lang="en-us" style="font-family: ''; mso-bidi-font-size: 9.0pt">.<br>      set sub_folders=cur_folder.subfolders<p></p></span></p> <p class="msonormal" style="margin: 0cm 0cm 0pt; text-indent: 27pt; mso-char-indent-count: 2.57; mso-char-indent-size: 10.5pt"><span lang="en-us" style="font-family: ''; mso-bidi-font-size: 9.0pt">' </span><span style="font-family: 宋体; mso-ascii-font-family: ''; mso-hansi-font-family: ''; mso-bidi-font-size: 9.0pt">建立当前目录的子目录对象集合</span><span lang="en-us" style="font-family: ''; mso-bidi-font-size: 9.0pt">.<br>      for each each_sub_folder in sub_folders<p></p></span></p> <p class="msonormal" style="margin: 0cm 0cm 0pt; text-indent: 16.5pt"><span lang="en-us" style="font-family: ''; mso-bidi-font-size: 9.0pt">  ' </span><span style="font-family: 宋体; mso-ascii-font-family: ''; mso-hansi-font-family: ''; mso-bidi-font-size: 9.0pt">对子目录集合进行遍历</span><span lang="en-us" style="font-family: ''; mso-bidi-font-size: 9.0pt">.<br>          if each_sub_folder.attributes=16 then<p></p></span></p> <p class="msonormal" style="margin: 0cm 0cm 0pt; text-indent: 16.5pt"><span lang="en-us" style="font-family: ''; mso-bidi-font-size: 9.0pt">      ' </span><span style="font-family: 宋体; mso-ascii-font-family: ''; mso-hansi-font-family: ''; mso-bidi-font-size: 9.0pt">确定子目录的属性为普通子目录</span><span lang="en-us" style="font-family: ''; mso-bidi-font-size: 9.0pt">.<br>          sub_v_path=v_path&"/"&each_sub_folder.name<br>          sub_c_path=c_path&"\"&each_sub_folder.name<p></p></span></p> <p class="msonormal" style="margin: 0cm 0cm 0pt; text-indent: 16.5pt"><span lang="en-us" style="font-family: ''; mso-bidi-font-size: 9.0pt">      ' </span><span style="font-family: 宋体; mso-ascii-font-family: ''; mso-hansi-font-family: ''; mso-bidi-font-size: 9.0pt">得到当前的子虚拟绝对路径与真实绝对路径</span><span lang="en-us" style="font-family: ''; mso-bidi-font-size: 9.0pt">.<br>            p=search_file(search_data,sub_v_path,sub_c_path)<p></p></span></p> <p class="msonormal" style="margin: 0cm 0cm 0pt; text-indent: 16.5pt"><span lang="en-us" style="font-family: ''; mso-bidi-font-size: 9.0pt">        ' </span><span style="font-family: 宋体; mso-ascii-font-family: ''; mso-hansi-font-family: ''; mso-bidi-font-size: 9.0pt">调用文件检索函数对当前子目录下的文件进行字符串匹配检索</span><span lang="en-us" style="font-family: ''; mso-bidi-font-size: 9.0pt">.<br>            p=search_folder(search_data,sub_v_path,sub_c_path)<p></p></span></p> <p class="msonormal" style="margin: 0cm 0cm 0pt; text-indent: 16.5pt"><span lang="en-us" style="font-family: ''; mso-bidi-font-size: 9.0pt">        ' </span><span style="font-family: 宋体; mso-ascii-font-family: ''; mso-hansi-font-family: ''; mso-bidi-font-size: 9.0pt">递归检索当前子目录的下一级目录</span><span lang="en-us" style="font-family: ''; mso-bidi-font-size: 9.0pt">.<br>          end if<br>      next<br>      set each_sub_folder=nothing<br>      set sub_folders=nothing<br>      set cur_folder=nothing<br>      set file_system=nothing<p></p></span></p> <p class="msonormal" style="margin: 0cm 0cm 0pt; text-indent: 16.5pt"><span lang="en-us" style="font-family: ''; mso-bidi-font-size: 9.0pt">  ' </span><span style="font-family: 宋体; mso-ascii-font-family: ''; mso-hansi-font-family: ''; mso-bidi-font-size: 9.0pt">清除服务器端对象</span><span lang="en-us" style="font-family: ''; mso-bidi-font-size: 9.0pt">.<br>  end if <br>  end function<br><br>function search_file(search_data,v_path,c_path)<br>  dim file_system,sub_files,sub_file_v_path,sub_out_v_path<p></p></span></p> <p class="msonormal" style="margin: 0cm 0cm 0pt; text-indent: 10.5pt; mso-char-indent-count: 1.0; mso-char-indent-size: 10.5pt"><span lang="en-us" style="font-family: ''; mso-bidi-font-size: 9.0pt">' </span><span style="font-family: 宋体; mso-ascii-font-family: ''; mso-hansi-font-family: ''; mso-bidi-font-size: 9.0pt">文件匹配检索函数</span><span lang="en-us" style="font-family: ''; mso-bidi-font-size: 9.0pt">.<br>  if not isempty(c_path) then<p></p></span></p> <p class="msonormal" style="margin: 0cm 0cm 0pt"><span lang="en-us" style="font-family: ''; mso-bidi-font-size: 9.0pt">  ' </span><span style="font-family: 宋体; mso-ascii-font-family: ''; mso-hansi-font-family: ''; mso-bidi-font-size: 9.0pt">确认路径不为空</span><span lang="en-us" style="font-family: ''; mso-bidi-font-size: 9.0pt">.<br><br>    set file_system=createobject("scripting.filesystemobject")<br>    set cur_folder=file_system.getfolder(c_path)<br>    set sub_files=cur_folder.files<p></p></span></p> <p class="msonormal" style="margin: 0cm 0cm 0pt; text-indent: 16.5pt"><span lang="en-us" style="font-family: ''; mso-bidi-font-size: 9.0pt">' </span><span style="font-family: 宋体; mso-ascii-font-family: ''; mso-hansi-font-family: ''; mso-bidi-font-size: 9.0pt">建立检索目录下的文件对象集合</span><span lang="en-us" style="font-family: ''; mso-bidi-font-size: 9.0pt">.<br>    for each each_file in sub_files<p></p></span></p> <p class="msonormal" style="margin: 0cm 0cm 0pt; text-indent: 16.5pt"><span lang="en-us" style="font-family: ''; mso-bidi-font-size: 9.0pt">' </span><span style="font-family: 宋体; mso-ascii-font-family: ''; mso-hansi-font-family: ''; mso-bidi-font-size: 9.0pt">遍历文件对象集合</span><span lang="en-us" style="font-family: ''; mso-bidi-font-size: 9.0pt">.<br>        if instr(each_file.name,search_data)<>0 then<p></p></span></p> <p class="msonormal" style="margin: 0cm 0cm 0pt; text-indent: 16.5pt"><span lang="en-us" style="font-family: ''; mso-bidi-font-size: 9.0pt">    ' </span><span style="font-family: 宋体; mso-ascii-font-family: ''; mso-hansi-font-family: ''; mso-bidi-font-size: 9.0pt">匹配字符串与文件名</span><span lang="en-us" style="font-family: ''; mso-bidi-font-size: 9.0pt">.<br>            sub_file_v_path=v_path&"/"&each_file.name<p></p></span></p> <p class="msonormal" style="margin: 0cm 0cm 0pt; text-indent: 16.5pt"><span lang="en-us" style="font-family: ''; mso-bidi-font-size: 9.0pt">        ' </span><span style="font-family: 宋体; mso-ascii-font-family: ''; mso-hansi-font-family: ''; mso-bidi-font-size: 9.0pt">建立可用链接</span><span lang="en-us" style="font-family: ''; mso-bidi-font-size: 9.0pt">,</span><span style="font-family: 宋体; mso-ascii-font-family: ''; mso-hansi-font-family: ''; mso-bidi-font-size: 9.0pt">输出匹配文件</span><span lang="en-us" style="font-family: ''; mso-bidi-font-size: 9.0pt">.<p></p></span></p> <p class="msonormal" style="margin: 0cm 0cm 0pt; text-indent: 16.5pt"><span lang="en-us" style="font-family: ''; mso-bidi-font-size: 9.0pt">            sub_out_v_path=replace(sub_file_v_path," ","%20")<p></p></span></p> <p class="msonormal" style="margin: 0cm 0cm 0pt; text-indent: 16.5pt"><span lang="en-us" style="font-family: ''; mso-bidi-font-size: 9.0pt">            ' </span><span style="font-family: 宋体; mso-ascii-font-family: ''; mso-hansi-font-family: ''; mso-bidi-font-size: 9.0pt">替换路径及文件名中出现的空格</span><span lang="en-us" style="font-family: ''; mso-bidi-font-size: 9.0pt">.<br>            response.write("<p><a href=" & sub_out_v_path & _<br>                        ">"&sub_file_v_path&"</a>")<br>        end if <br>    next<br>    set sub_out_v_path=nothing<br>    set sub_file_v_path=nothing<br>    set each_file=nothing<br>    set sub_files=nothing<br>    set file_system=nothing<br>  end if<br>end function<br></script><br><br><hr><br></body></html></span></p> <p></p> <p align="center"><b>[1]</b></p> </div> <div class="info-pre-next"> <p> 上一篇: <a href="/article/598542.html"> jsp文件下载功能实现代码 </a> </p> <p> 下一篇: <a href="/article/598544.html"> 四川专科补录时间出来了吗?2021四川专科补录什么时候开始?(最新公布) </a> </p> </div> <div class="wz_tuijian"> <p> 推荐阅读 </p> <ul> <li> <a href="/article/2162387.html" target="_blank" title="Linux中如何查询运行文件的全路径的方法"> <h2> Linux中如何查询运行文件的全路径的方法 </h2> </a> </li> <li> <a href="/article/2078367.html" target="_blank" title="如何查询笔记本电脑的保修期"> <h2> 如何查询笔记本电脑的保修期 </h2> </a> </li> <li> <a href="/article/1996060.html" target="_blank" title="在Linux上如何使用fuser工具来查询文件的用户"> <h2> 在Linux上如何使用fuser工具来查询文件的用户 </h2> </a> </li> <li> <a href="/article/1895334.html" target="_blank" title="如何在线查询本地机的文件?"> <h2> 如何在线查询本地机的文件? </h2> </a> </li> <li> <a href="/article/1767718.html" target="_blank" title="Linux中如何查询运行文件的全路径的方法"> <h2> Linux中如何查询运行文件的全路径的方法 </h2> </a> </li> <li> <a href="/article/1397034.html" target="_blank" title="请教如何查询系统最近5天生成的txt文件并提供链接给访问者上载"> <h2> 请教如何查询系统最近5天生成的txt文件并提供链接给访问者上载 </h2> </a> </li> <li> <a href="/article/1329634.html" target="_blank" title="如何用php把查询出来的文件导出成excel表格的形式呢"> <h2> 如何用php把查询出来的文件导出成excel表格的形式呢 </h2> </a> </li> <li> <a href="/article/1317608.html" target="_blank" title="如何用php把查询出来的文件导出成excel表格的形式呢"> <h2> 如何用php把查询出来的文件导出成excel表格的形式呢 </h2> </a> </li> <li> <a href="/article/1305700.html" target="_blank" title="如何查询笔记本电脑的保修期"> <h2> 如何查询笔记本电脑的保修期 </h2> </a> </li> <li> <a href="/article/1128635.html" target="_blank" title="请教如何查询系统最近5天生成的txt文件并提供链接给访问者上载"> <h2> 请教如何查询系统最近5天生成的txt文件并提供链接给访问者上载 </h2> </a> </li> </ul> </div> </article> </div> </main> <footer><div class="box"><div class="ft_nav"><div class="ft_about"><p>关于网站</p><ul><li><a href="/sitemap.xml" target="_blank" title="网站地图">网站地图</a></li><li><a href="/list/2/" title="最新程序员文章站">最新程序员文章站</a></li></ul></div><div class="ft_contact"><ul><li>本站所有数据收集于网络如有侵犯到您的权益,请联系我们进行下架处理。</li><li class="email_show"></li></ul></div></div><div class="copyright"><div class="cr_left"><p> 备案号:<a href="https://beian.miit.gov.cn/#/Integrated/index" target="_blank">粤ICP备20058927号</a></p><p>© Copyright © 2020-2022 www.superweb999.com 程序员文章站. </p></div></div></div></footer> </body> </html>