Posted by ImOk on 06/09/06 02:40
Chung Leong wrote:
> ImOk wrote:
> > WHen I run this under Windows I get the Count of drives but then I get
> > an error message on the Reset() when I try to enumerate. Does this work
> > for anyone?
> >
> > $fs = new COM("Scripting.FileSystemObject");
> > $drives = $fs->Drives;
> > echo $drives->Count;
> > $drives->Reset();
> > while($drive = $drives->Next()) {
> > echo $drive->VolumeName;
> > }
> >
> >
> > 2PHP Stack trace: PHP 1. {main}() C:\PHP5Apps\PHPX\fso.php:0 PHP Fatal
> > error: Call to undefined method variant::Reset() in
> > C:\PHP5Apps\PHPX\fso.php on line 5
>
> I think it was I who posted that fragment. The code only works in PHP
> 4. In PHP 5, you just enumerate $drives as though it's a regular array.
> Hence:
>
> $fs = new COM("Scripting.FileSystemObject");
> $drives = $fs->Drives;
> foreach($drives as $drive) {
> echo $drive->DriveLetter;
> }
I had tried the enumeration later and it worked fine. But thanks anyway.
Navigation:
[Reply to this message]
|