473,804 Members | 3,058 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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. FileSystemObjec t");
$drives = $fs->Drives;
echo $drives->Count;
$drives->Reset();
while($drive = $drives->Next()) {
echo $drive->VolumeName;
}
2PHP Stack trace: PHP 1. {main}() C:\PHP5Apps\PHP X\fso.php:0 PHP Fatal
error: Call to undefined method variant::Reset( ) in
C:\PHP5Apps\PHP X\fso.php on line 5

Jun 8 '06 #1
2 1937

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. FileSystemObjec t");
$drives = $fs->Drives;
echo $drives->Count;
$drives->Reset();
while($drive = $drives->Next()) {
echo $drive->VolumeName;
}
2PHP Stack trace: PHP 1. {main}() C:\PHP5Apps\PHP X\fso.php:0 PHP Fatal
error: Call to undefined method variant::Reset( ) in
C:\PHP5Apps\PHP X\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. FileSystemObjec t");
$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. FileSystemObjec t");
$drives = $fs->Drives;
echo $drives->Count;
$drives->Reset();
while($drive = $drives->Next()) {
echo $drive->VolumeName;
}
2PHP Stack trace: PHP 1. {main}() C:\PHP5Apps\PHP X\fso.php:0 PHP Fatal
error: Call to undefined method variant::Reset( ) in
C:\PHP5Apps\PHP X\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. FileSystemObjec t");
$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
19406
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 OpenOffice. I know in *nix I can start by using "/" as the file name and doing a recursive listing of the file system from there. (Yes -- I know about permissions to read directories -- that's another issue I've already solved.) How do I find the...
162
7298
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 (microsoft.com, cnn.com, etc.) at the W3 Validator; to my surprise none of them passed. Doesn't anyone care anymore, or are the standards more-or-less looked at as guidlines for web design?
13
4138
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#, 'blah'); and then save the query, close it, and then reopen by clicking the design button so it opens in sql view. The sql has changed to:
4
1350
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 drives? My initial thought was along the lines of DirectoryInfo di = new DirectoryInfo( "c:\\"); DirectoryInfo Root = new DirectoryInfo( di.Parent.Name.ToString() ); DirectoryInfo RootDrives = Root.GetDirectories();
3
1864
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 automatically generated, and the objectdatasource let you design against a business object through the gui. Now I am working on my first real web application on 2.0, and I find this automatic functionality doesn't do much beyond allowing me to generate...
0
2358
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 limited Success because there is a bug apparently in using IWshRuntimeLibrary. There must be some API calls to get this information since Windows Explorer seems to be able to get. Can anyone tell me what API's are used. I know GetLogicalDrivesA...
15
2579
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 if BerConverter is supported for Win2000 server? http://msdn2.microsoft.com/en-us/library/system.directoryservices.protocols.berconverter.decode.aspx -- Thanks.
1
7118
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 someone who bothers to read all of it have some pointers. Note, I have posted the stack trace and the code exhibiting the problem further down so if you want to start by reading that, search for +++ Also note that I am unable to reproduce...
1
2046
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
9704
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9569
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10558
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10318
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10302
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
5503
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5636
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4277
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2975
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.