PDA

View Full Version : GetFolder Method


CarlInDaHouse
01-14-2003, 06:40 AM
I am trying to write a script that will allow me to check a CDRW drive to see if any files exist. I tried this already

Set myFolder = fso.GetFolder("Y:")
WScript.Echo(myFolder.Files.Count)

I get an error saying "No more files". Is there another way to test for files when the might or might not be files on the disk. I wont know the filenames directly.

Jama
01-24-2003, 08:08 AM
I don’t know what version of WSH you are using but your code works fine!
Anyway, use an If…Then statement whenever you want to check for the existence of a file or folder.

Set fso = CreateObject("Scripting.FileSystemObject")
Set myFolder = fso.GetFolder("a:")
If myFolder.Files.Count > 0 Then
'Your code here!
Else
'Your Code Here!
End If

Jama