The GetObjectSize method is used to retrieve the
size of a stored object on the server. This method can also be used as
a simple method to determine if the specified object exists. An object
size of zero means the object exists, but currently has no data associated
with it.
If the first version of this method is called, where the object
size is a return value, you can distinguish between an error and an
empty object by calling the GetLastError method. If
the last error code is NO_ERROR then the object exists, but it has no
data associated with it. Any other error code value indicates the
reason the object size could not be returned.
If the second version of this method is used and the lpObjectSize
parameter is not NULL, its value is initialized to zero when the method is
called, and updated with the object size when the method returns.
Although storage object labels are similar to Windows file names,
they are case-sensitive. When requesting the size of an object, your
application must specify the label name exactly as it was created. The
object label cannot contain wildcard characters.
The GetObjectInformation method can be used
to obtain the metadata associated with the storage object, including
the size, content type, creation date and a SHA-256 digest of the data.
To obtain information about how much storage your applications are
using and the total number of stored objects, use the
GetStorageQuota method.
DWORD dwObjectSize = 0;
if (pStorage->GetObjectSize(lpszObjectLabel, &dwObjectSize))
{
_tprintf(_T("The size of \"%s\" is %lu bytes\n"), lpszObjectLabel, dwObjectSize);
}
else
{
CString strError;
pStorage->GetErrorString(strError);
_tprintf(_T("Unable to get the size of \"%s\" (%s)\n"), lpszObjectLabel, (LPCTSTR)strError);
}