Thanks giga, the library works fine, but in this way you have many methods and only drive letters C: D : E: F:
If you example has 1 or more USB Splitter and more pendrive or HD, maybe need letters G: H: I: L: etc .... ....
I think the best way would be to enumerate each drive, so
you can get letters from A : (floppy) to Z: (last unit available in the system)
So for example, you can control the drivers by INDEX :
' Read Free space on all Drivers by index
Dim jDS As jDiskSpace
For Each driveIndex As Byte = jDS.GetNumberOfDrivers()
Log ("Disk Index:" & driveIndex & " Free:" & jDS.getFreeSpaceByIndex(driveIndex) &_
" Total:" & jDS.getTotalSpaceByIndex(driveIndex) &_
" Useable:" & jDS.getUseableSpaceByIndex(driveIndex) &_
" Used:" & jDS.getUsedSpaceByIndex(driveIndex))
Next
Or with simple For loop (same by INDEX):
' Same but using simple For loop
Dim jDS As jDiskSpace
Dim driveIndex as byte
For driveIndex = 0 to (jDS.GetNumberOfDrivers()-1)
Log ("Disk Index:" & driveIndex & " Free:" & jDS.getFreeSpaceByIndex(driveIndex) &_
" Total:" & jDS.getTotalSpaceByIndex(driveIndex) &_
" Useable:" & jDS.getUseableSpaceByIndex(driveIndex) &_
" Used:" & jDS.getUsedSpaceByIndex(driveIndex))
Next
or by NAME :
Dim jDS As jDiskSpace
Log ("Free disk space on the floppy is " & jDS.getFreeSpaceByLetter("A")) ' should always be the first letter, but as in modern PCs
' no longer used the floppy, maybe to A: drive is assigned to another
' Read infos on Drive C: by LETTER
If jDS.getDriveExistsByLetter("C") then ' check if drive C exists
Log ("Free disk space on C: is " & jDS.getFreeSpaceByLetter("C:"))
Log ("Total disk space on C: is " & jDS.getTotalSpaceByLetter("C:"))
Log ("Useable space on drive C: is " & jDS.getUseableSpaceByLetter("C:"))
Log ("Used disk space on C: is " & jDS.getUsedSpaceByLetter("C:"))
Next
' Read infos on drive D: by LETTER
If jDS.getDriveExistsByLetter("D") then ' check if drive D exists
Log ("Free space on D: is " & jDS.getFreeSpaceByLetter("D:"))
Log ("Total disk space on D: is " & jDS.getTotalSpaceByLetter("D:"))
Log ("Useable space on D: is " & jDS.getUseableSpaceByLetter("D:"))
Log ("Used space on D: is " & jDS.getUsedSpaceByLetter("D:"))
Next
' Read Free space on PenDrive by LETTER
If jDS.getDriveExistsByLetter("E:") then Log ("Free space on PenDrive is " & jDS.getFreeSpaceByLetter("E:"))
' ............. WE CAN CONTINUE WITH DRIVER UNITS ( FROM A: TO Z: ) ..............
' ...............................................................................
' ...............................................................................
jmon is absolutely right , I agree with him ... in this way would be much better and you could iterate through the driver units in a For loop or For Each, While, etc ... ...
It would be a nice thing to also be able to differentiate the types of units as jmon says, so you know if a unit is a PenDrive, HD, CDROM, etc ... ...
This is possible Because The system I can read infos on Units classified ... (see Resource Explorer)
Sub GetDriveType(Byte Index, String Type) as Boolean ' test type of Drive
That return boolean know this possible example:
Letter can be "A:", "B:", "C:" etc ... ...
Type can be "ALL", "CDROM", "REMOVABLE", "NETWORK", "FIXED" etc ... ...
' Write all infos on FIXED Units (like fixed HD)
Dim jDS As jDiskSpace
For Each driveIndex As Byte = jDS.GetNumberOfDrivers()
If jDs.GetDriveType(driveIndex,"FIXED")
Log ("Found FIXED Drive Drive infos Free:" & jDS.getFreeSpaceByIndex(driveIndex) &_
" Total:" & jDS.getTotalSpaceByIndex(driveIndex) &_
" Useable:" & jDS.getUseableSpaceByIndex(driveIndex) &_
" Used:" & jDS.getUsedSpaceByIndex(driveIndex))
Next
Next
' Write all infos on REMOVABLE Units (like removable HD, PenDrive etc...)
Dim jDS As jDiskSpace
For Each driveIndex As Byte = jDS.GetNumberOfDrivers()
If jDs.GetDriveType(driveIndex,"REMOVABLE")
Log ("Found REMOVABLE Drive Drive infos Free:" & jDS.getFreeSpaceByIndex(driveIndex) &_
" Total:" & jDS.getTotalSpaceByIndex(driveIndex) &_
" Useable:" & jDS.getUseableSpaceByIndex(driveIndex) &_
" Used:" & jDS.getUsedSpaceByIndex(driveIndex))
Next
Next
Sorry for my bud english but i'm italian...
I'm new user, i use B4J from 5 days and seem very good...
How to create additional libraries for B4J? Need to use Java or possible using only Class in B4J IDE?
I've created some libraries for other languages, so i want translate to B4J
Can someone please explain how to do it?