获取所要查讯文件夹所在磁盘剩余空间的大小
源代码在线查看: 获取任意文件夹的大小.txt
// floderNum.cpp : Defines the entry point for the console application.
//获取本地电脑上任意文件夹的大小,结果以MB为单位
#include
#import "scrrun.dll" raw_interfaces_only
int main()
{
char *pathFloder = "c:\\data";
CoInitialize(NULL);
{
try
{
Scripting::IFileSystem3Ptr fs;
fs.CreateInstance(__uuidof(Scripting::FileSystemObject));
Scripting::IFolderPtr folder;
fs->GetFolder(_bstr_t(pathFloder),&folder);
_variant_t vsize;folder->get_Size(&vsize);
printf("%4.6fMB\n",(long)vsize/1024.0/1024.0);
}
catch(_com_error &e)
{
_bstr_t bstrSource(e.Source());
_bstr_t bstrDescription(e.Description());
std::cout std::cout std::cout }
}
CoUninitialize();
return 0;
}