rheffels
(Lurker)
2006-11-15 12:10 PM
GetDiskSpace function not working properly ?

How come that the following script is reporting the same size for dir1 as dir2 ?
Am I missing something here ?
Both dirs exist though...

SIZE.KIX
Open( 1 , "size.csv" , 5 )
WriteLine( 1 , "dir1;" + GetDiskSpace("F:\DIR1") + ";" + @CRLF )
WriteLine( 1 , "dir2;" + GetDiskSpace("F:\DIR2") + ";" + @CRLF )
Close ( 1 )

SIZE.CSV
dir1;43303784;
dir2;43303784;


Benny69
(MM club member)
2006-11-15 01:54 PM
Re: GetDiskSpace function not working properly ?

Hi rheffels,
Welcome to the korg, I believe what is going on, is that ‘GetDiskSpace(< drive letter >:)’ is not designed to look at directories,
it only looks at drives and because both dir's you have there are both on drive F.

You could try fnGetFolderProp(). I think it will get you what you are looking for.


rheffels
(Lurker)
2006-11-15 02:07 PM
Re: GetDiskSpace function not working properly ?

That's what I thought, but that's not what it says in the command reference
http://www.kixtart.org/index.asp?p=commandRef#_Toc146265755

"On Windows NT and on Windows 95 OSR2 and later versions, Drive does not have to specify the root directory on a disk. On these platforms, the function accepts any directory on a disk."

And it doesn't work on Windows XP Professional and Windows 2003 Server.
So... Is it a bug or something ? :-)


Richard H.Administrator
(KiX Supporter)
2006-11-15 02:40 PM
Re: GetDiskSpace function not working properly ?

You mis-understand the comments in the manual.

Although you can supply any directory, it is still the drive space that is returned.

If you read through it again you will see that it never says that it returns directory space. It only refers to returning drive space.


Chris S.
(MM club member)
2006-11-15 03:49 PM
Re: GetDiskSpace function not working properly ?

Here is the direct link to fnGetFolderProp().

rheffels
(Lurker)
2006-11-16 04:04 PM
Re: GetDiskSpace function not working properly ?

Ah, thanks for the function, it works !
But the documentation of GetDiskSpace() is a bit odd...
Why would you want to specify a directory if you get the space available on the drive ?
You might as well specify the drive then...


Arend_
(MM club member)
2006-11-16 05:53 PM
Re: GetDiskSpace function not working properly ?

Here's a simple script to get disk space and size.
Written this in 2 mins, a personal record
Code:

Function DiskSpace
Dim $WshShell, $fso, $Drive, $DriveCol, $drv
$WshShell = CreateObject("WScript.Shell")
$fso = CreateObject("Scripting.FileSystemObject")
$DriveCol = $fso.Drives
For Each $Drive in $DriveCol
If $Drive.DriveType = 2
$drv = $fso.GetDrive($Drive)
? "Free Space of " + $Drive " = " + $drv.FreeSpace / 1024 / 1024 / 1024 + " GB"
? "Total Space of " + $Drive " = " + $drv.TotalSize / 1024 / 1024 / 1024 + " GB"
EndIf
Next
EndFunction



Sealeopard
(KiX Master)
2006-11-17 05:40 AM
Re: GetDiskSpace function not working properly ?

URL found in 10 seconds :-)

DiskSpace() - returns the available disk space on a drive


NTDOCAdministrator
(KiX Master)
2006-11-17 07:51 AM
Re: GetDiskSpace function not working properly ?

The GAVEN principal

Arend_
(MM club member)
2006-11-19 02:35 PM
Re: GetDiskSpace function not working properly ?

LOL nice one