2023年7月6日发(作者:)
c++进⾏⽂件复制⼀、⾸先头⽂件的包括#include "Shellapi.h"#include "tchar.h"#pragma comment(lib,"")
⼆、字符的转换std::string 类型转换成 LPCWSTR 类型LPCWSTR stringToLPCWSTR(std::string orig){ size_t origsize = () + 1; const size_t newsize = 100; size_t convertedChars = 0; wchar_t *wcstring = (wchar_t *)malloc(sizeof(wchar_t)*(() - 1)); mbstowcs_s(&convertedChars, wcstring, origsize, orig.c_str(), _TRUNCATE); return wcstring;}三、函数的引⽤/拷贝⼀个⽂件 和 拷贝⼀个⽂件夹基本⼀致 区别在于路径 ⼀个是⽂件路径⼀个是⽂件夹路径void _copeFile(std::string & strPath,std::string & desPath){ SHFILEOPSTRUCT fop; = FO_COPY; //选择执⾏类型,FO_COPY,FO_DELETE,FO_RENAME,FO_MOVE四种操作 = stringToLPCWSTR(strPath); //源⽂件来源 = stringToLPCWSTR(desPath); //⽬的⽂件 = FOF_SILENT | FOF_NOCONFIRMATION | FOF_NOERRORUI | FOF_NOCONFIRMMKDIR; SHFileOperation(&fop);}
发布者:admin,转转请注明出处:http://www.yc00.com/xiaochengxu/1688598480a153675.html
评论列表(0条)