Reply to Re: Does this method for getting drives work for anyone?

Your name:

Reply:


Posted by Chung Leong on 06/08/06 17:57

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;
}

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация