首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > ASP >

怎么用FSO提取文件夹中所有文件并分页

2012-02-22 
如何用FSO提取文件夹中所有文件并分页如何用FSO提取文件夹中所有文件并分页程序代码:%pageSize1fder p

如何用FSO提取文件夹中所有文件并分页
如何用FSO提取文件夹中所有文件并分页

程序代码:
<%      
pageSize=1  
fder= "pic "        
Set       fso       =       CreateObject( "Scripting.FileSystemObject ")        
set       objfolder=fso.GetFolder(server.mappath(fder))        
%>  
            <table   width= "720 "   border= "0 "   cellspacing= "0 "   cellpadding= "0 ">
<%  
for   each   objfile   in   objfolder.files      
if   FileCount> =pageSize   then  
elseif   c> pageSize*(CurrentPage-1)   then
%>  
                <tr   onMouseOver= "this.bgColor= '#EAEAEA ' "   onMouseOut= "this.bgColor= ' ' ">
                    <td   width= "160 "   height= "130 "   align= "center "> <div   style= "position:relative;width:150px;height:120px;overflow:hidden;border:1px   solid   #CCCCCC; "> <img   src= <%=(fder   &   "/ "   &   objfile.name)%>   width= "150 "   border= "0 "> </div> </td>
                    <td   width= "66 "   height= "130 "   align= "center "> <input   name= "ddd "   type= "checkbox "   id= "ddd "   value= " <%=(fder   &   "/ "   &   objfile.name)%> "> </td>
                    <td   width= "494 "   height= "130 "   style= "word-break   :   break-all; "   class= "font2 "> <%=(fder   &   "/ "   &   objfile.name)%> </td>
                    </tr>
                <tr>
<%    
FileCount=FileCount+1  
end   if    
next    
%>  
                    <td   height= "60 "   align= "center "> <input   type= "submit "   name= "Submit "   value= "执行删除任务 "> </td>
                </tr>
            </table>

[解决办法]
你先得到文件夹下文件数目,然后再计算分页。

[解决办法]
<% on error resume next

pageSize=3
fder= "../a "
Set fso = CreateObject( "Scripting.FileSystemObject ")
set objfolder=fso.GetFolder(server.mappath(fder))
%>
<form name= "form1 " method= "post " action= "?action=delfile ">

<table width= "720 " border= "1 " align= "center " cellpadding= "0 " cellspacing= "0 " bordercolor= "#CCCCCC ">


<%

pageFileCount=0
for each objfile in objfolder.files
if FileCount <=pageSize-1 then
'elseif c> pageSize*(CurrentPage-1) then
'redim files(FileCount)
%>
<tr onMouseOver= "this.bgColor= '#EAEAEA ' " onMouseOut= "this.bgColor= ' ' ">
<td width= "160 "align= "center "> <%=FileCount+1%> </td>
<td width= "66 " align= "center "> <input name= "files <%=FileCount%> " type= "checkbox " value= " <%=(fder & "/ " & objfile.name)%> "> </td>
<td width= "494 " style= "word-break : break-all; " class= "font2 "> <%=( objfile.name)%> </td>
</tr>

<%
FileCount=FileCount+1
end if
next
%> <tr>
<td height= "60 " align= "center "> <input type= "submit " name= "Submit " value= "执行删除任务 "> </td>
</tr>
</table>
</form>
<%if request( "action ")= "delfile " then
for i=0 to FileCount-1
if trim(request( "files "& i)) <> " " then
'response.write trim(request( "files "& i))
fso.deletefile(server.MapPath(fder & "/ " & trim(request( "files "& i))))
end if
next
response.Write " <script language=javascript> alert( '删除成功! '); "
response.write "window.location.href= '?action= '; </script> "
response.End()
response.Redirect "?action= "
end if
If Err Then
err.Clear
Response.Write " <script language=javascript> alert( '文件不存在,请检查是否输入正确!! '); </script> " '注释,需要把这几个字翻译成英文。
response.End()
End If
%>

热点排行