0
votes

I get the compiler error Incompatible types: 'Byte' and 'String' on the following function:

IntToStr(DiskSize('F:\'))

I want to convert the disk size to a string. How to solve this problem?

1
You could easily have answered this question yourself by simply having a look at the documentation of DiskSize. After all, if you haven't used a funcion before, you always consult the documentation before you use it, especially if you don't know how to use it, like in this case. - Andreas Rejbrand
I agree with you, but I am a newer so, I will some easy problems. I will try to read the documentation. - John Elder

1 Answers

4
votes

The argument for DiskSize is a byte (hence, not a string) where 0 is current drive, 1=A, 2=B etc. so for drive F you want DiskSize(6), or more generally a function to do this would be:

function DiskSizeL(DriveLetter: Char): Int64;
begin
  DriveLetter := UpCase(DriveLetter);
  Result := DiskSize(1 + Ord(DriveLetter) - Ord('A'));
end;

You would want to check that the char was in the range A to Z though etc.