Check mapped network drive size

1

I'm developing an application, and I need to check the free space on the mapped network drive, I can grab the contents of a file in the directory of my application, then I created a script to execute the command to check the free space in batch :

unidade  := 'Z:';
caminho  := ExtractFileDir(Application.ExeName);
vCommand := 'fsutil volume diskfree '+unidade+' | find /i "livres disp" > '+caminho+'\unidade.txt';
WinExec(PChar('cmd /c "'+vCommand+'" '),SW_SHOWNORMAL);

With the code above, and changing the drive to c: , I get the expected return, but when I change to Z: , it does not work.

Or if you'd have another way to do this, I'm using .

    
asked by anonymous 13.04.2017 / 21:38

1 answer

1

Try this way

var
  FreeAvailable,TotalSpace,TotalFree : Int64;
begin
  GetDiskFreeSpaceEx('z:',FreeAvailable,TotalSpace,@TotalFree);
  ShowMessage('Espaço livre: '+FormatFloat('#,0',TotalFree));
end;

Source: link .

    
13.04.2017 / 22:21