1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
|
<%
Dim X
X = CountLineInFolder("d:\mon_dossier")
Response.Write X
FUNCTION CountLineInFolder(Path)
Dim FSO, Folder, Extension, LineTotal, FolderContent, FileList, File
LineTotal = 0
Set FSO = Server.CreateObject("Scripting.FileSystemObject")
Folder = FSO.GetAbsolutePathName(Path)
Set FolderContent= FSO.GetFolder(Path)
Set FileList = FolderContent.Files
FOR EACH File IN FileList
Extension = FSO.GetExtensionName(File)
IF lcase(Extension) = "port" THEN
LineTotal = LineTotal + CountLine(File)
END IF
NEXT
CountLineInFolder = LineTotal
END FUNCTION
FUNCTION CountLine(FileName)
Const ForReading = 1
Const ForWriting = 2
Const ForAppending = 8
Dim filetxt, NbLine, FSO, Content
Set FSO = Server.CreateObject("Scripting.FileSystemObject")
NbLine = 0
Set filetxt = FSO.OpenTextFile(FileName, ForReading, True)
DO WHILE NOT filetxt.atEndOfStream
Content = filetxt.ReadLine
IF replace(Content, " ", "") <> "" THEN
NbLine = NbLine + 1
END IF
LOOP
NbLine = NbLine - 2
filetxt.Close
CountLine = NbLine
END FUNCTION
%> |
Partager