473,322 Members | 1,401 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Does this method for getting drives work for anyone?

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

Jun 8 '06 #1
2 1919

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

Jun 8 '06 #2

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.

Jun 9 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Hal Vaughan | last post by:
I've seen install programs that search a hard drive for previous instances of a program, or to find installs of other needed programs. I need to search a hard drive for any installations of...
162
by: Isaac Grover | last post by:
Hi everyone, Just out of curiosity I recently pointed one of my hand-typed pages at the W3 Validator, and my hand-typed code was just ripped to shreds. Then I pointed some major sites...
13
by: Peter James | last post by:
Access 97 If I select New on the Query tab of the db window, and go staight to sql view and type in the following for example: INSERT INTO tblMyTable ( dtDate, txtAny) VALUES (#2003-09-03#,...
4
by: Phillip N Rounds | last post by:
I need to eumerate all available drives in a C# Windows Form application ( and then of course the directory tree, but that's not the problem) My question is, how to I enumerate all the available...
3
by: John Bailey | last post by:
When I first built a few web pages in ASP .Net 2.0, I thought it was great. The formview and detailview contorls would automatically layout the controls for you, the update methods were...
0
by: Dennis | last post by:
I have tried to use the IWshRuntimeLibrary and ManagementObjectSearcher("SELECT * FROM Win32_LogicalDisk") to get all Logical Drives, Mapped Network Drives, Shared Folders and Shared Drives with...
15
by: Pucca | last post by:
I'm getting an error when I tried to use this BerConverter class in my C# code. Even though the Interent doc says that it runs on Win2000 sp4, I just thgouth I'll double check. Does anyone know...
1
by: =?ISO-8859-1?Q?Lasse_V=E5gs=E6ther_Karlsen?= | last post by:
I get the above error in some of the ASP.NET web applications on a server, and I need some help figuring out how to deal with it. This is a rather long post, and I hope I have enough details that...
1
by: visweswaran2830 | last post by:
I want to get mounted and unmounted drives using vb.net. Could anyone help me. Using getlogicaldrives methods we can get mounted drive. but i want to get unmounted drives also.
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.