Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > how to determine number of files in directory? array question

Reply
Thread Tools

how to determine number of files in directory? array question

 
 
Bart Plessers \(artabel\)
Guest
Posts: n/a
 
      09-04-2003
Hello,

I have an asp script that lists the files in a directory:

CurrentPATH = "c:\temp\"
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oFolder = oFSO.GetFolder(CurrentPATH)
Set oFolderContents = oFolder.Files
For Each oFileItem in oFolder.Files
.....
next


However,
before doing the "For..Next" loop, I want to determine the number of files
in oFolderContents.

How can I do this?
Is there another way to determine the number of files in a given directory?

tia

bartp





--
HyperART
Paul Van Ostaijenlaan 4
3001 Heverlee



 
Reply With Quote
 
 
 
 
Ken Schaefer
Guest
Posts: n/a
 
      09-04-2003
The Files collection has a .Count() property that returns the number of
Files in the collection;

obj.Files.Count()

where obj is a Folder object. Check the WSH reference, which you can
download from here:
http://www.microsoft.com/downloads/d...displaylang=en

Cheers
Ken



"Bart Plessers (artabel)" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
: Hello,
:
: I have an asp script that lists the files in a directory:
:
: CurrentPATH = "c:\temp\"
: Set oFSO = CreateObject("Scripting.FileSystemObject")
: Set oFolder = oFSO.GetFolder(CurrentPATH)
: Set oFolderContents = oFolder.Files
: For Each oFileItem in oFolder.Files
: .....
: next
:
:
: However,
: before doing the "For..Next" loop, I want to determine the number of files
: in oFolderContents.
:
: How can I do this?
: Is there another way to determine the number of files in a given
directory?
:
: tia
:
: bartp
:
:
:
:
:
: --
: HyperART
: Paul Van Ostaijenlaan 4
: 3001 Heverlee
:
:
:


 
Reply With Quote
 
 
 
 
Bart Plessers \(artabel\)
Guest
Posts: n/a
 
      09-04-2003
Hi ken,

thanx for quick reply.

However, I can't get away with the syntax.
Can you clearify a little bit?
Maybe provide the correct syntax for my example below?

> : CurrentPATH = "c:\temp\"
> : Set oFSO = CreateObject("Scripting.FileSystemObject")
> : Set oFolder = oFSO.GetFolder(CurrentPATH)
> : Set oFolderContents = oFolder.Files
> : For Each oFileItem in oFolder.Files
> : .....
> : next





tia

bart





--
HyperART
Paul Van Ostaijenlaan 4
3001 Heverlee

"Ken Schaefer" <(E-Mail Removed)> wrote in message
news:e#(E-Mail Removed)...
> The Files collection has a .Count() property that returns the number of
> Files in the collection;
>
> obj.Files.Count()
>
> where obj is a Folder object. Check the WSH reference, which you can
> download from here:
>

http://www.microsoft.com/downloads/d...C48-207D-4BE1-
8A76-1C4099D7BBB9&displaylang=en
>
> Cheers
> Ken
>
>
>
> "Bart Plessers (artabel)" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> : Hello,
> :
> : I have an asp script that lists the files in a directory:
> :
> : CurrentPATH = "c:\temp\"
> : Set oFSO = CreateObject("Scripting.FileSystemObject")
> : Set oFolder = oFSO.GetFolder(CurrentPATH)
> : Set oFolderContents = oFolder.Files
> : For Each oFileItem in oFolder.Files
> : .....
> : next
> :
> :
> : However,
> : before doing the "For..Next" loop, I want to determine the number of

files
> : in oFolderContents.
> :
> : How can I do this?
> : Is there another way to determine the number of files in a given
> directory?
> :
> : tia
> :
> : bartp
> :
> :
> :
> :
> :
> : --
> : HyperART
> : Paul Van Ostaijenlaan 4
> : 3001 Heverlee
> :
> :
> :
>
>



 
Reply With Quote
 
Bart Plessers \(artabel\)
Guest
Posts: n/a
 
      09-04-2003
sorry, found it already with your VERY helpfull link!!

syntax:
MyCount = oFolderContents.count

without the brackets...


thanx a lot again

bart



--
HyperART
Paul Van Ostaijenlaan 4
3001 Heverlee

"Bart Plessers (artabel)" <(E-Mail Removed)> wrote in message
news:#(E-Mail Removed)...
> Hi ken,
>
> thanx for quick reply.
>
> However, I can't get away with the syntax.
> Can you clearify a little bit?
> Maybe provide the correct syntax for my example below?
>
> > : CurrentPATH = "c:\temp\"
> > : Set oFSO = CreateObject("Scripting.FileSystemObject")
> > : Set oFolder = oFSO.GetFolder(CurrentPATH)
> > : Set oFolderContents = oFolder.Files
> > : For Each oFileItem in oFolder.Files
> > : .....
> > : next

>
>
>
>
> tia
>
> bart
>
>
>
>
>
> --
> HyperART
> Paul Van Ostaijenlaan 4
> 3001 Heverlee
>
> "Ken Schaefer" <(E-Mail Removed)> wrote in message
> news:e#(E-Mail Removed)...
> > The Files collection has a .Count() property that returns the number of
> > Files in the collection;
> >
> > obj.Files.Count()
> >
> > where obj is a Folder object. Check the WSH reference, which you can
> > download from here:
> >

>

http://www.microsoft.com/downloads/d...C48-207D-4BE1-
> 8A76-1C4099D7BBB9&displaylang=en
> >
> > Cheers
> > Ken
> >
> >
> >
> > "Bart Plessers (artabel)" <(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed)...
> > : Hello,
> > :
> > : I have an asp script that lists the files in a directory:
> > :
> > : CurrentPATH = "c:\temp\"
> > : Set oFSO = CreateObject("Scripting.FileSystemObject")
> > : Set oFolder = oFSO.GetFolder(CurrentPATH)
> > : Set oFolderContents = oFolder.Files
> > : For Each oFileItem in oFolder.Files
> > : .....
> > : next
> > :
> > :
> > : However,
> > : before doing the "For..Next" loop, I want to determine the number of

> files
> > : in oFolderContents.
> > :
> > : How can I do this?
> > : Is there another way to determine the number of files in a given
> > directory?
> > :
> > : tia
> > :
> > : bartp
> > :
> > :
> > :
> > :
> > :
> > : --
> > : HyperART
> > : Paul Van Ostaijenlaan 4
> > : 3001 Heverlee
> > :
> > :
> > :
> >
> >

>
>



 
Reply With Quote
 
Ken Schaefer
Guest
Posts: n/a
 
      09-05-2003
Sorry about the brackets - I was just "quoting from memory" - obviously I
got it a little bit wrong! Glad you got it working!

Cheers
Ken

"Bart Plessers (artabel)" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
: sorry, found it already with your VERY helpfull link!!
:
: syntax:
: MyCount = oFolderContents.count
:
: without the brackets...
:
:
: thanx a lot again
:
: bart
:
:
:
: --
: HyperART
: Paul Van Ostaijenlaan 4
: 3001 Heverlee
:
: "Bart Plessers (artabel)" <(E-Mail Removed)> wrote in message
: news:#(E-Mail Removed)...
: > Hi ken,
: >
: > thanx for quick reply.
: >
: > However, I can't get away with the syntax.
: > Can you clearify a little bit?
: > Maybe provide the correct syntax for my example below?
: >
: > > : CurrentPATH = "c:\temp\"
: > > : Set oFSO = CreateObject("Scripting.FileSystemObject")
: > > : Set oFolder = oFSO.GetFolder(CurrentPATH)
: > > : Set oFolderContents = oFolder.Files
: > > : For Each oFileItem in oFolder.Files
: > > : .....
: > > : next
: >
: >
: >
: >
: > tia
: >
: > bart
: >
: >
: >
: >
: >
: > --
: > HyperART
: > Paul Van Ostaijenlaan 4
: > 3001 Heverlee
: >
: > "Ken Schaefer" <(E-Mail Removed)> wrote in message
: > news:e#(E-Mail Removed)...
: > > The Files collection has a .Count() property that returns the number
of
: > > Files in the collection;
: > >
: > > obj.Files.Count()
: > >
: > > where obj is a Folder object. Check the WSH reference, which you can
: > > download from here:
: > >
: >
:
http://www.microsoft.com/downloads/d...C48-207D-4BE1-
: > 8A76-1C4099D7BBB9&displaylang=en
: > >
: > > Cheers
: > > Ken
: > >
: > >
: > >
: > > "Bart Plessers (artabel)" <(E-Mail Removed)> wrote in message
: > > news:(E-Mail Removed)...
: > > : Hello,
: > > :
: > > : I have an asp script that lists the files in a directory:
: > > :
: > > : CurrentPATH = "c:\temp\"
: > > : Set oFSO = CreateObject("Scripting.FileSystemObject")
: > > : Set oFolder = oFSO.GetFolder(CurrentPATH)
: > > : Set oFolderContents = oFolder.Files
: > > : For Each oFileItem in oFolder.Files
: > > : .....
: > > : next
: > > :
: > > :
: > > : However,
: > > : before doing the "For..Next" loop, I want to determine the number of
: > files
: > > : in oFolderContents.
: > > :
: > > : How can I do this?
: > > : Is there another way to determine the number of files in a given
: > > directory?
: > > :
: > > : tia
: > > :
: > > : bartp
: > > :
: > > :
: > > :
: > > :
: > > :
: > > : --
: > > : HyperART
: > > : Paul Van Ostaijenlaan 4
: > > : 3001 Heverlee
: > > :
: > > :
: > > :
: > >
: > >
: >
: >
:
:


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
how to determine array element number in a each loop Kaya Aykut Ruby 3 07-30-2010 03:36 PM
frequency count or number of occurences of a number in an array Larry Python 5 03-13-2008 06:46 PM
OT: Number Nine, Number Nine, Number Nine FrisbeeŽ MCSE 37 09-26-2005 04:06 PM
nuby: determine method passed and determine the receiver that received the method Peņa, Botp Ruby 1 01-24-2004 07:51 PM



Advertisments