How to check free space on memory card
Article Metadata
Tested with
Devices(s): N78
Compatibility
Platform(s): S60 3rd,3rd FP1, 3rd Fp2
Platform Security
Signing Required: Self Signed
Article
Keywords: keywords=TDriveInfo,TDriveInfo::Drive(),TDriveInfo::Volume()
Created: lming
(01 Nov 2008)
Last edited: hamishwillee
(22 Nov 2011)
This snippet shows how the application can check whether there is enough free space on a memory card before attempting to save a file.
Source file
//necessary library
LIBRARY efsrv.lib
//necessary header file
#include <f32file.h>
RFs fileSession;
TVolumeInfo volumeInfo;
//open RFs session
fileSession.Connect();
//freeSpace will store number of free memory card in Bytes
TBuf<64> freeSpace;
TInt64 freeKBytes;
//Contains drive information.
TDriveInfo driveInfo;
//check all drives from A to Z
for (TInt driveNumber=EDriveA; driveNumber<=EDriveZ; driveNumber++)
{
//Gets information of this drive
fileSession.Drive(driveInfo,driveNumber);
//if this drive is EMediaNANDFlash,we find drive of Memory card
// also reported my DiBo Members that on some devices it can be EMediaHardDisk
// ref: [http://www.developer.nokia.com/Community/Discussion/showthread.php?156990-Free-system-memory]
if(driveInfo.iType == EMediaNANDFlash)
{
//recode its free space in bytes
fileSession.Volume(volumeInfo,driveNumber);
freeKBytes = volumeInfo.iFree/1024;
freeSpace.Num(freeKBytes);
break;
}
}
....
//close RFs session
fileSession.Close();
Postconditions
The freeSpace variable the free memory space in bytes, on the memory card.
Internal Links:


Note from the moderators:
Code is incorrect
EMediaNANDFlash - it is type for internal memory, so called sysmtem drive. So you are measuring free memory on system drive, not memory card.
Jp4symbian - Memory card or mass memory?
Has anyone figured out how to differentiate memory card from mass memory. Both have similar TDriveInfo type of EMediaHardDisk.
Also PathInfo::MemoryCardRootPath() returns the Mass memory drive rather than the Memory card drive.jp4symbian 16:00, 13 October 2011 (EEST)
Hamishwillee - See response to other query
Look up KDriveAttRemovablehamishwillee 03:53, 14 October 2011 (EEST)