⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 获取任意文件夹的大小.txt

📁 获取所要查讯文件夹所在磁盘剩余空间的大小
💻 TXT
字号:
// floderNum.cpp : Defines the entry point for the console application.
//获取本地电脑上任意文件夹的大小,结果以MB为单位
#include <iostream>   
#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<<"Get directory size via FileSystemObject, by masterz"<<std::endl;   
			std::cout<<"COM error occurred,source:"<<(LPCTSTR)bstrSource<<std::endl;   
			std::cout<<"Description:"<<(LPCTSTR)bstrDescription<<std::endl;   
		}
	}
	CoUninitialize();
	return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -