获取所要查讯文件夹所在磁盘剩余空间的大小

源代码在线查看: 获取任意文件夹的大小.txt

软件大小: 2 K
上传用户: liu4052032
关键词: 磁盘
下载地址: 免注册下载 普通下载 VIP

相关代码

				// 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;
				}
							

相关资源