|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
File Count problem
hello,
i am using javascript to access files in a particular folder.I am doing this locally on my machine only. My script counts the number of files of a particular type and beginning with a particular character (eg 'r'). My script works fine. Now when I go in and try and change the contents of the folder, like add a file or rename a file, and then rerun my javascript it does not work correctly. i get some file names but not all. i am posting part of my code here. Please look into this and let me know what I am doing wrong. thanks, ************************ //this function is called by the main program function countFiles(strPath,num,fp) { icount=0; var objFSO = new ActiveXObject("Scripting.FileSystemObject"); //creation of filesystem object var objFolder = objFSO.GetFolder(strPath); var objFiles = objFolder.Files; var filesCount = objFiles.Count; //filecount var a1=new Array(filesCount); var a2=new Array(filesCount); i=0; for(var objEnum = new Enumerator(objFiles); ! objEnum.atEnd(); objEnum.moveNext()) { strFileName = objEnum.item().name; strFileName1 = objEnum.item().type; // WScript.Echo(strFileName); a1[i]=strFileName; a2[i]=strFileName1; i++; } objEnum=null; var a3=new Array(); //selection of files based on extension and starting char of name for(i=0;i<filesCount;i++) { var p=a1[i].charAt(0); if(p==cmpch & a2[i]=="PNG Image" ) { icount++; a3[i]=a1[i]; var a3_l=a3[i].length; a3[i]=a3[i].substring(0,a3_l-4); } } //after this I write out contents to output file. } |
|
#2
|
|||
|
|||
|
followup to code
just wanted to mention that in my code, i use two arrays to hold the file name and type of each file. (a1 & a2).
I use strFileName = objEnum.item().name; a1[i]=strFileName; I define the arrays using a1=new Array(); do i maybe need to define the array as a string array which can hold strings? thanks and sorry for any confusion. eagerly hoping for some input. |
|
#3
|
|||
|
|||
|
THis is a vb forum!Plz administrator move this message to other forum as "HTML, JavaScript & CSS"...
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > Visual Basic Programming > File Count problem |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|