| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1475 人关注过本帖
标题:FSO分页排列问题
只看楼主 加入收藏
hmhz
Rank: 7Rank: 7Rank: 7
等 级:贵宾
威 望:30
帖 子:1890
专家分:503
注 册:2006-12-17
结帖率:100%
收藏
 问题点数:0 回复次数:5 
FSO分页排列问题
FSO读取文件夹里所有图片,然后按照横5竖3的方式排列,并且分页,程序我已经写好了,问题在按照横5竖3排列就比较难了,对FSO比较熟悉的兄弟帮我修改一下这个程序

<table width="100%" border="1" cellpadding="0" style="border-collapse:collapse" cellspacing="0" bordercolor="#D4D0C8">
<tr height="18" align="center" bgcolor="#19A1DD" style="color:#fff;">
<td colspan="5">我的相册</td>
</tr>
<tr bgcolor="#f9f9f9" align="center">
<%
Page=Request.QueryString("Page")
if Page="" then Page=1 else Page=cint(Page) end if
PatentFolder = "pic/2007联欢会/" '图片文件夹
FoldPage = 15
Set Fso = CreateObject("Scripting.FileSystemObject")
if Fso.FolderExists(Server.Mappath(PatentFolder)) then
Set FolderCount = Fso.GetFolder(Server.Mappath(PatentFolder)).files
For Each F1 in FolderCount
if (Page-1)*FoldPage<=i and i<(Page-1)*FoldPage+FoldPage then  '循环部分
%>
<td height="170">
<img src="<%=PatentFolder&F1.Name%>" style="width:150px; height:119px;" /><br>
<%=F1.DateLastAccessed%><br>
<input type="button" value="删除"  style="cursor:pointer; width:30px; height:16px;" />
</td>
<%
end if
i=i+1
next
ThePageCount = Sgn(FolderCount.Count/FoldPage)+fix(FolderCount.Count/FoldPage)-1  '总页数
TheFileCount = FolderCount.Count  '总记录数
Set FolderCount = Nothing
Set Fso = Nothing
%>
</tr>
<tr align="center" bgcolor="#e7e7e7" height="20">
<td colspan="15">
<%
 Response.Write "共<b>"&TheFileCount&"</b>张  共<b>"&ThepageCount&"</b>页  当前第<b>"&page&"</b>页  "
 Response.Write "<a href=?page=1>首页</a> "
 IF page>1 Then
  Response.Write "<a href=?page="&page-1&">上一页</a> "
 Else
  Response.Write "上一页 "
 End IF
 
 IF page<ThepageCount Then
  Response.Write "<a href=?page="&page+1&">下一页</a> "
 Else
  Response.Write "下一页 "
 End IF
 Response.Write "<a href=?page="&ThepageCount&">尾页</a>  "
Else
 Response.write "无指定目录"
End IF
%>
</td>
</tr>
</table>
搜索更多相关主题的帖子: FSO 排列 
2008-02-04 15:48
yms123
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:209
帖 子:12488
专家分:19042
注 册:2004-7-17
收藏
得分:0 
也就是说每行5个来排列?
其实分页算法个人认为不仅可以用在分页上,这里也可以灵活运用
最近写的一个灵活运用分页算法的例子
function PagesClass()
{
   this.PSize=0;
   this.PageCount=0;
   this.PCount=0;
   this.PCurrent=0;
   this.PNumAry;
   this.getDInt=function(NumA,NumB)
   {
      var NumC;
      if(NumA%NumB==0)
         NumC=parseInt(NumA/NumB);
      else
         NumC=parseInt(NumA/NumB)+1;
      return NumC;
   };
   this.InitPageClass=function()
   {
       this.PCount=this.getDInt(this.PageCount,this.PSize);
   };
   this.getLastPNum=function()
   {
       return (this.PCurrent-1)*this.PSize;
   };
   this.getPNumAry=function()
   {
      this.PNumAry=new Array(this.PSize);
      var LPN=this.getLastPNum();
      var PSi=0;
      for(var i=(LPN+1);i<=(LPN+this.PSize);i++)
      {
         if(PSi<this.PSize)
         {      
            if(i<=this.PageCount)
            {
                  this.PNumAry[PSi]=i;
            }
            else
               this.PNumAry[PSi]=-1;  
            PSi++;  
         }
      }
   };
}
var PGCls=new PagesClass();
   var ShowDiv=document.geElementById("Show_Div");
   PGCls.PageCount=DataArray.length;
   PGCls.PSize=5;//按照每行5个图片的方法分页
   PGCls.InitPageClass();
   var reHtml="";
   for(var r=0;r<PGCls.PCount;r++)
   {
       PGCls.PCurrent=r;
       PGCls.getPNumAry();
       reHtml+="<table width=163 border=0 cellpadding=0 cellspacing=0 >";
       reHtml+="<tr>";
       for(var c=0;c<PGCls.PNumAry;c++)
       {
           reHtml+="<td width=71 height=70 valign=top >"
           reHtml+="<table width=71 border=0 cellpadding=0 cellspacing=0 >";
           reHtml+="<tr>";
           reHtml+="<td width=71 height=57 valign=middle >";
           reHtml+="<div align=center >";
           reHtml+="<img name=Icon src="+DataArray[PGCls.PNumAry][0]+" border=0 width=48 height=49 >";
           reHtml+="</div>";
           reHtml+="</td>";
           reHtml+="</tr>";
           reHtml+="<tr>";
           reHtml+="<td height=13 valign=top >";
           reHtml+="<div align=center >";
           reHtml+="<FONT size=3 face=仿宋_GB2312 >";
           reHtml+=DataArray[PGCls.PNumAry][1];
           reHtml+="</FONT>";
           reHtml+="</div>";
           reHtml+="</td>";
           reHtml+="<tr>";
           reHtml+="</table>";
           reHtml+="<td width=12 >&nbsp;</td>";
       }
       reHtml+="</tr>";
       reHtml+="</table>";
   }
   ShowDiv.innerHTML=reHtml;
2008-02-04 17:54
hmhz
Rank: 7Rank: 7Rank: 7
等 级:贵宾
威 望:30
帖 子:1890
专家分:503
注 册:2006-12-17
收藏
得分:0 
问题是FSO直接获取文件夹文件,而不是从数据库获取数据条数,所以无法使用记录集来排列,FSO还不太会灵活运用,毕竟这个东西很少用
2008-02-04 18:07
yms123
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:209
帖 子:12488
专家分:19042
注 册:2004-7-17
收藏
得分:0 
那的确比较麻烦,个人想先把文件名和路径读入数组里然后分页。但这种做法用ASP做还是比较费资源,因为首先遍历文件夹下所有图片很费资源。然后分页程序要通过算法对图片数据进行筛选式读取,同样费资源。
2008-02-04 19:07
不惑
Rank: 2
等 级:论坛游民
威 望:2
帖 子:569
专家分:13
注 册:2007-3-22
收藏
得分:0 
这是以前人写的一个文件.看看你用不用得上:

 <%@LANGUAGE="VBSCRIPT"%>   
  <html>   
  <head>   
  <META   http-equiv=Content-type   content=text/html;charset=GB2312>   
  </head>   
  <body   bgcolor='#B6CFB6'>   
  <%   
  on   error   resume   next   
   
  '这部份用于认证用户权限   
  'if   Request.Cookies("myweb")("username")=""   then   
  ' Response.Redirect("../logon_tmp.asp?gotov=mh/index.asp")   
  ' Response.End   
  'else   
  ' Response.Write   "<center>您好,"   &   Request.Cookies("myweb")("username")   &"<br><a   href='../news/UserEdit.asp'>修改资料</a>&nbsp;<a   href='../news/logout.asp?gobak=1'>退出登陆</a></center><br><br><br>"   
  'end   if   
   
   
  '根据需要设置参数   
  PageCount=15'                                                                           每页显示的个数   
  strFileName="index.asp"   
  strdir="../"'                                                                       设置显示的初始目录   
   
   
   
  Function   IsObjInstalled(strClassString)       '测试控件有没有安装的函数,此页用于测试FSO,见后面调用   
  On   Error   Resume   Next   
  IsObjInstalled   =   False   
  Err   =   0   
  Dim   xTestObj   
  Set   xTestObj   =   Server.CreateObject(strClassString)   
  If   0   =   Err   Then   IsObjInstalled   =   True   
  Set   xTestObj   =   Nothing   
  Err   =   0   
  End   Function   
   
  if   request("page")<>""   then   
          currentPage=cint(request("page"))     '当前页码   
  else   
          currentPage=1   
  end   if   
  MaxPerPage=PageCount   
  UploadDir   =   request("parentPath")               '要列出的文件夹名称,相对于此页面文件所在根目录来说   
  if   UploadDir=""   then   UploadDir=strdir   
  TruePath=Server.MapPath(UploadDir)         '获得全路径   
  If   not   IsObjInstalled("Scripting.FileSystemObject")   Then         '测试是否支持FSO   
  Response.Write   "<b><font   color=red>你的服务器不支持   FSO(Scripting.FileSystemObject)!   不能使用本功能</font></b>"   
  Else   
  set   fso=CreateObject("Scripting.FileSystemObject")       '如果支持FSO就创建FSO对象   
  if   fso.FolderExists(TruePath)then'如果指定的目录存在就计算目录中文件数量,并列举文件   
  FileCount=0   
  subFolderCount=0   
  TotleSize=0   
  TotleSize2=0   
  Set   theFolder=fso.GetFolder(TruePath)   
          For   Each   thesubfolder   in   theFolder.SubFolders'计算子文件夹的个数   
                  subFolderCount=subFolderCount+1   
          Next   
  For   Each   theFile   In   theFolder.Files'   计算文件的个数   
  FileCount=FileCount+1                       '计算总文件数   
  TotleSize2=TotleSize2+theFile.Size         '计算总文件容量   
  next   
  totalPut=FileCount+subFolderCount         '总文件、子目录数   
  if   currentpage<1   then   
        currentpage=1   
  end   if   
  if   (currentpage-1)*MaxPerPage>totalput   then         '计算当前页码   
  if   (totalPut   mod   MaxPerPage)=0   then   
  currentpage=   totalPut   \   MaxPerPage   
  else   
      currentpage=   totalPut   \   MaxPerPage   +   1   
  end   if   
  end   if   
  if   currentPage=1   then   
  showContent   '罗列文件   
  showpage2   strFileName,totalput,MaxPerPage,UploadDir   
  response.write   "<br/><div   align='center'>本页共显示   <b>"   &   FileCount   &   "</b>   个文件,占用   <b>"   &   TotleSize\1024   &   "</b>   K</div>"   
  else   
  if   (currentPage-1)*MaxPerPage<totalPut   then   
  showContent            
  showpage2   strFileName,totalput,MaxPerPage,UploadDir   
  response.write   "<br/><div   align='center'>本页共显示   <b>"   &   FileCount   &   "</b>   个文件,占用   <b>"   &   TotleSize\1024   &   "</b>   K</div>"   
  else   
  currentPage=1   
  showContent            
  showpage2   strFileName,totalput,MaxPerPage,UploadDir   
  response.write   "<br/><div   align='center'>本页共显示   <b>"   &   FileCount   &   "</b>   个文件,占用   <b>"   &   TotleSize\1024   &   "</b>   K</div>"   
  end   if   
  end   if   
      else   
  response.write   "找不到文件夹!可能是配置有误!"   
      end   if   
  end   if   
   
  sub   showContent()'罗列文件及子文件夹的子过程   
        dim   c   
  FileCount=0   
  TotleSize=0   
  %>   
  <form   action=""   name="form1"   method="post">   
  <table   width="95%"   border="1"   cellspacing="0"   cellpadding="3"   align="center"   bordercolorlight="#ECEEE4"   bordercolordark="#CCCABC">   
            <tr>     
              <td   colspan="5"   align="center"   height="30"   background="image/tablebg.gif"><b>上               理</b>   </td>   
          </tr>   
          <tr   align="center"   valign="middle">     
  <td   height="25">文件名</td>   
  <td   height="25">文件大小</td>   
  <td   height="25">文件类型</td>   
  <td   height="25">最后修改时间</td>   
  </tr>   
  <%   
  if   UploadDir<>strdir   then   
  %>   
          <tr   align="center"   valign="middle">     
        <td   height="25"><a   href="<%=strFileName%>?page=1&parentPath=<%=left(UploadDir,instrrev(UploadDir,"/")-1)%>"><strong>..</strong></a>(返回上级目录)</td>   
  <td   height="25"></td>   
    <td   height="25"> </td>   
  <td   height="25"> </td>   
    </tr>   
  <%   
  end   if   
          For   Each   thesubfolder   in   theFolder.SubFolders   '罗列子文件夹的代码   
  c=c+1   
  if   FileCount>=MaxPerPage   then   
  exit   for   
  elseif   c>MaxPerPage*(CurrentPage-1)   then   
  %>   
  <tr   align="center"   valign="middle">   
  <td   height="25"><a   href="<%=strFileName%>?page=1&parentPath=<%=(UploadDir   &   "/"   &   thesubfolder.Name)%>"><strong>   
  <%   
  ba=split(thesubfolder.Name,".")   
  response.write   ba(0)   
  %>   
  </strong></a></td>   
      <td   height="25"> </td>   
      <td   height="25"> </td>   
      <td   height="25"> </td>   
  </tr>   
  <%   
  FileCount=FileCount+1   
  end   if   
  Next   
  For   Each   theFile   In   theFolder.Files'罗列文件的代码   
  c=c+1   
  if   FileCount>=MaxPerPage   then   
  exit   for   
  elseif   c>MaxPerPage*(CurrentPage-1)   then   
  %>   
  <tr   align="center"   valign="middle">   
  <td   height="25"><a   href="<%=(UploadDir   &   "/"   &   theFile.Name)%>"   target="_blank"><strong>   
   
  <%   
  ba=split(theFile.Name,".")   
  response.write   ba(0)   
  %>   
  </strong></a></td>   
  <td   height="25"><%=theFile.size%>字节</td>   
  <td   height="25"><%=theFile.type%></td>   
  <td   height="25"><%=theFile.DateLastModified%></td>   
  </tr>   
  <%   
  FileCount=FileCount+1   
  TotleSize=TotleSize+theFile.Size   
  end   if   
  Next   
  %>   
  </table>   
  </form>   
  <%   
  end   sub   
   
  sub   showpage2(sfilename,totalnumber,maxperpage,parentPath)'写页脚   
  dim   n,   i,strTemp   
  if   totalnumber   mod   maxperpage=0   then   
          n=   totalnumber   \   maxperpage   
  else   
          n=   totalnumber   \   maxperpage+1   
      end   if   
  strTemp=   "<table   align='center'><form   name='showpages'   method='Post'   action='"   &   sfilename   &   "'><tr><td>"   
  strTemp=strTemp   &   "共   <b>"   &   totalnumber   &   "</b>   个文件及子目录,占用   <b>"   &   TotleSize2\1024   &   "</b>   K&nbsp;&nbsp;&nbsp;"   
  if   CurrentPage<2   then   
          strTemp=strTemp   &   "首页   上一页&nbsp;"   
  else   
          strTemp=strTemp   &   "<a   href='"   &   sfilename   &   "?page=1&parentPath="&   parentPath   &"'>首页</a>&nbsp;"   
          strTemp=strTemp   &   "<a   href='"   &   sfilename   &   "?page="   &   (CurrentPage-1)   &   "&parentPath="&   parentPath   &"'>上一页</a>&nbsp;"   
    end   if   
   
  if   n-currentpage<1   then   
          strTemp=strTemp   &   "下一页   尾页"   
  else   
          strTemp=strTemp   &   "<a   href='"   &   sfilename   &   "?page="   &   (CurrentPage+1)   &   "&parentPath="&   parentPath   &"'>下一页</a>&nbsp;"   
          strTemp=strTemp   &   "<a   href='"   &   sfilename   &   "?page="   &   n   &   "&parentPath="&   parentPath   &"'>尾页</a>"   
      end   if   
        strTemp=strTemp   &   "&nbsp;页次:<strong><font   color=red>"   &   CurrentPage   &   "</font>/"   &   n   &   "</strong>页   "   
        strTemp=strTemp   &   "&nbsp;<b>"   &   maxperpage   &   "</b>"   &   "个文件/页"   
        strTemp=strTemp   &   "&nbsp;转到:<select   name='page'   size='1'   onchange='javascript:submit()'>"         
        for   i   =   1   to   n     
  strTemp=strTemp   &   "<option   value='"   &   i   &   "'"   
  if   cint(CurrentPage)=cint(i)   then   strTemp=strTemp   &   "   selected   "   
  strTemp=strTemp   &   ">第"   &   i   &   "页</option>"         
  next   
  strTemp=strTemp   &   "</select>"   
  strTemp=strTemp   &   "<input   type=hidden   name=parentPath   value="&parentPath&">"   
  strTemp=strTemp   &   "</td></tr></form></table>"   
  response.write   strTemp   
  end   sub   
  %>   
  </body>   
  </html>
2008-02-05 08:53
zjl998
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2010-1-25
收藏
得分:0 
自动换行,用CSS应该可以实现
2011-04-10 22:37
快速回复:FSO分页排列问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.020358 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved