View the resource manager in the Windows operating system is Microsoft's very successful file management software. Its left side is the tree view of the entire filesystem, and the right is the list of files (folders) for the current directory, providing a simple, user-friendly user interface for file management. However, Microsoft's IE browser does not provide similar functionality, if you can use browser-based/web server architecture to provide users with a Windows Explorer similar to the Remote file Management tool, will be greatly user-friendly. Based on this consideration, the author uses ASP technology to implement a remote file browser similar to Windows resource manager. This article describes how to implement a tree view of a directory, a file list view, and a file search three major sections.
Default.asp file
This file is the main file that constructs the framework for the entire interface.
<frameset rows= "80,20*" framespacing= "0" >
<frame name= "Pmain" scrolling= "Auto" noresize
target= "Contents" marginwidth= "1" marginheight= "1" src= "pmian.htm" >
<frameset cols= "230,530" >
<frame name= "Ptreeview" src= "ptreeview.asp?"
Vfdpath=<%=request ("Vfdpath")%>&mflag= "scrolling=" 1 "marginwidth=" 1 "marginheight=" 1 "noresize Auto" 1 ">
<frame name= "Plistview" src= "plistview.asp?"
Vfdpath=<%=request ("Vfdpath")%> "scrolling=" 1 "marginwidth=" 1 "marginheight=" 1 "noresize Auto" 1 ">
</frameset><noframes><body>
<p> because your browser does not support this Web page framework, you cannot browse this page </p>
</body> </noframes></frameset>ptreeview.asp file
This file is primarily responsible for the generation of the directory tree view. Its core function is Foldopen (), which is responsible for responding to user operations on the directory, such as opening a folder. The three parameters are described below:
Sflups: The current absolute virtual path;
RSFD: current physical path;
DEP: Current path depth (used to record recursive depth).
Another function, Unmappath (), is also called in this function, which returns the virtual path for the physical path (note: In the program in this article, all shared files are mapped to the virtual directory gpdir).
<%
vfd = request.querystring ("Vfdpath")
Mflag = Request.QueryString ("Mflag")
Server.ScriptTimeout = 500
On Error Resume Next
Set Obfs = Server.CreateObject
("Scripting.FileSystemObject")
Set Obfd=obfs. GetFolder (Server.MapPath ("/gpdir"))
Oblength = Len (Obfd.path)
Function Unmappath (Path)
S=mid (Path, oblength+1)
Unmappath = Replace (S, "\", "/")
End Function
Function Foldopen (SFLUPS,RSFD,DEP)
spic= "Width=16 height=16> "
If DEP <> 0 Then
spib= "<a href=" "Ptreeview.asp? Vfdpath= "
& "/gpdir/" & Unmappath (RSFD). Path)
Else
spib= "<a href=" "Ptreeview.asp? Vfdpath= "&"/gpdir "& Unmappath (RSFD. Path)
End If
SPIB=SPIB & "&mflag="
SPIB=SPIB & "C" "target=" "Ptreeview" ">"
Response.Write Spib & spic & "</a>"
spic= "spib= "<a href=" "Plistview.asp? Vfdpath= "
If DEP <> 0 Then
SPIB=SPIB & "/gpdir/" & Unmappath
(RSFD. Path) & "" "target=" "Plistview" ">"
Else
SPIB=SPIB & "/gpdir" & Unmappath (RSFD. Path) & "" "target=" "Plistview" ">"
End If
Response.Write Spib & spic & "</a></TD></TR>"
For each SFD in RSFD. Subfolders
Response.Write "<tr><td class=p9 height=16 width=" "100%" ">"
For Cn=0 to DEP
Response.Write "Next
If SFD. Subfolders.count>0 Then
If INSTR (1, sflups, "/gpdir/" & Unmappath (SFD). Path), vbTextCompare <> 1 Then
spic= "Padd.gif "" "Width=16 height=16>"
spib= "<a href=" "Ptreeview.asp? Vfdpath= "&"/gpdir/"& Unmappath (SFD. Path)
SPIB=SPIB & "&mflag="
SPIB=SPIB & "O" ""
SPIB=SPIB & "target=" "Ptreeview" ">"
Response.Write Spib & spic & "</a>"
spic= "Response.Write "<a href=" "Plistview
. asp? Vfdpath= "&"/gpdir/"& Unmappath (SFD. Path) & "" "target=" "Plistview" ">" "spic" </a></TD></TR> "
Else
Scdep=dep+1
Foldopen sflups, SFD, SCDEP
End If
Else
Response.Write "spic= "<img border=0 src=http://www.163design.net/a/q/" "Pic/pclose.gif"
"Width=16 height=16>" & SFD. Name
Response.Write "<a href=" "Plistview.asp?
Vfdpath= "&"/gpdir/"& Unmappath (SFD. Path) & "" "target=" "Plistview" ">" "spic" </a></TD></TR> "
End If
Next
End Function
%>
<base target= "main" ><body bgcolor= "#008080" text= "#ffffff" >
<table align=left border=0 cellpadding=0 cellspacing=0 width= "100%" >
<TR> <td width= "100%" >
</TD></TR><TR>
<TD height=16 width= "100%" >