Skip to content

getVolumeSpace

xiao edited this page Nov 8, 2025 · 1 revision

get the total space and free space of a volume for the current user. which means the result can be different from the physical space when disk quota is enabled.

usage

callback:

fswin.getVolumeSpace(path, callback);

async:

var result = await fswin.getVolumeSpaceAsync(volume);

sync:

var result = fswin.getVolumeSpaceSync(volume);
  • path is the root path of a volume.
  • callback is a function that takes only one argument result.
  • result is an object that contains 2 properties: TOTAL and FREE or null when the volume is inaccessible.

example

var fswin = require('fswin');
var path = 'c:\\';
//sync
var result = fswin.getVolumeSpaceSync(path);
console.log('total space is: ' + result.TOTAL + ' Bytes, free sapce is' + result.FREE + ' Bytes.');

//async
console.log(fswin.getVolumeSpace(path, function (result) {
	console.log('total space is: ' + result.TOTAL + ' Bytes, free sapce is' + result.FREE + ' Bytes.');
}) ? 'job queued' : 'failed to queue job');

Clone this wiki locally