热门文章
 
fso操作文件 实例函数
利用FSO取得BMP,JPG
FileSystemObje
fso使用:drive 读取
fso:folder 文件系
fso:file 文件对象
scripting.Text
ASP实现结构化列举并查看某
Adodb.Stream
ASP 批量文件改名
 推荐文章
 
asp无组件读取图片文件信息
限制(禁用)FSO组件的方法
fso使用例子:创建文件夹
fso:file 文件对象
fso应用中的几个小函数
ASP FSO相关的一些例子
fso的一些特殊功能
FSO读取网站系统使用空间的
使用FSO修改文件夹的名称
fso复制文件夹所有内容和删
FSO操作文件系统代码
稻香老农的无组件上传类(完整
一个基于Jscript和fs
无惧 无组件上传完整代码
asp静态模版技术之标签参数
无组件上传文件被杀毒软件误报
 
你现在的位置:您现在的位置是: 中国ASP>>ASP教程>>fso组件
fso相关自定义函数:计算所有的asp和js的文件总数

<%
"\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
"
"\\    来自 codeproject.com
"    计算js和asp代码
"\\    修改 bluedestiny
"    mail:bluedestiny at 126.com
"\\

 

option explicit
response.buffer=false 
 

class COUNT_CODE
private fso,spath
private asplines, jslines, aspbytes, jsbytes, aspwords
private sub class_initialize
  set fso = createobject("scripting.filesystemobject") 
end sub
private sub class_terminate
  set fso=nothing
end sub
private function iterate(path)
  dim folder, folders, files, file, ts, txt, arr, f
  set folder = fso.getfolder(path)
  set files = folder.files
  dim rx, c
  set rx = new regexp
  rx.ignorecase = true
  rx.global = true
  rx.pattern = "  +"
  for each file in files
   if right(file.name,4)=".asp" or right(file.name,3)=".js" then
    set ts = file.openastextstream
    if ts.atendofstream then txt = "" else txt = ts.readall
    ts.close
    txt = rx.replace(txt," ")
    txt = replace(txt,vbcrlf&vbcrlf,vbcrlf)
    arr = split(replace(txt,vbcrlf," ")," ")
    aspwords = aspwords + ubound(arr)
    arr = split(txt,vbcrlf)
    if right(file.name,4)=".asp" then
     asplines = asplines + ubound(arr)
     aspbytes = aspbytes + len(txt)
    else
     jslines = jslines + ubound(arr)
     jsbytes = jsbytes + len(txt)
    end if
   end if
  next
  set folders = folder.subfolders
  for each f in folders
   iterate f.path
  next
end function 
 

public property let path(s)
  spath=server.mappath(s)
end property
public sub count
  iterate(spath)
end sub
public sub printf
  response.write "ASP:" & "<br/>"
  response.write "Total Lines Coded: " & asplines & "<br/>"
  response.write "Total Bytes: " & aspbytes & "" & "<br/>"
  response.write "Total Individual Elements (words) Typed: " & aspwords & "<br/>"
  response.write "JScript:" & "<br/>"
  response.write "Total Lines Coded: " & jslines & "<br/>"
  response.write "Total Bytes: " & jsbytes
end sub
end class 
 

"\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
"示例代码
"\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ 
 

dim o
set o=new COUNT_CODE
o.path="bluedestiny/"
o.count
o.printf
%> 


相关信息:

fso操作文件 实例函数
利用FSO取得BMP,JPG,PNG,GIF文件信息
FileSystemObject对象成员概要
fso使用:drive 读取驱动器信息
fso:folder 文件系统
fso:file 文件对象
scripting.TextStream对象-fso读写文本
ASP实现结构化列举并查看某路径下所有文件

 

中国ASP技术 ASP.ORG.CN 版权所有 2004-2008