您现在的位置是:网站首页> 编程资料编程资料

类似于iis浏览的功能_FSO专题_

2023-05-25 181人已围观

简介 类似于iis浏览的功能_FSO专题_


<%
'const_domain_name为域名最后不要加斜杠
const const_domain_name="http://localhost"
%>


<%
'------------------------------------------------显示当前目录下的子目录和文件
sub list
Dim fso, f, f1, fc, s
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder(server.MapPath("."))
set fs=f.SubFolders
Set fc =f.Files

For Each fss in fs
dim folder_name
folder_name=fss.name
%>
0<%=folder_name%>

<%
Next

%>
<%
For Each f1 in fc
dim filename
filename=f1.name
%>
/<%=filename%>

<%
Next

set fso=nothing
end sub
%>


<%
'------------------------------------------------显示指定路径下的目录和文件
sub list_cur
Dim fso, f, f1, fc, s
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder(request("cur_path"))
set fs=f.SubFolders
Set fc =f.Files

For Each fss in fs
dim folder_name
folder_name=fss.name
%>
0<%=folder_name%>

<%
Next

%>


<%
For Each f1 in fc
dim filename
filename=f1.name
%>
/<%=filename%>

<%
Next
set fso=nothing
end sub
%>



<%
'------------------------------------------------显示上级目录的子目录和子文件
sub list_parent
on error resume next
Dim fso, f, f1, fc, s
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder(display_cur_path)
set fs=f.SubFolders
Set fc =f.Files

For Each fss in fs
dim folder_name
folder_name=fss.name

%>
0<%=folder_name%>

<%

Next

%>

<%
For Each f1 in fc
dim filename
filename=f1.name
%>
/<%=filename%>

<%
Next
set fso=nothing
on error goto 0
end sub

'---------------------------------------------得到上级目录的路径
function get_parent_folder()
on error resume next
str=display_cur_path
str_find="\"
str_int=InStrRev (str,str_find)-1 '得到上一级目录的路径
get_parent_folder=mid(str,1,str_int)
err.clear
end function


'-----------------------------------------------将文件路径转为www发布的路径这样就可以下载了
function p2v_path(p_path)
'p_path为硬盘上的物理路径
dim host
host=lcase(server.MapPath("\"))
p_path=lcase(p_path)
p2v_path=replace(p_path,host,const_domain_name)
end function

'-----------------------------------------------显示当前所在的路径
function display_cur_path()
cur_path=request("cur_path")
if cur_path="" then
display_cur_path=server.MapPath(".")
else
display_cur_path=cur_path
end if
set fso=nothing
end function

sub main
%>
向上<%=display_cur_path%>


<%

select case request("act")
case "list_parent"
list_parent
case "list_cur"
list_cur
case else
list
end select
end sub


main
%>

-六神源码网