- 博客(0)
- 资源 (4)
空空如也
复制目录中的文件
复制某一给定目录下的文件
void FileCopyTo(CString source, CString destination, CString searchStr, BOOL cover = TRUE)
{
CString strSourcePath = source;
CString strDesPath = destination;
CString strFileName = searchStr;
CFileFind filefinder;
CString strSearchPath = strSourcePath + _T("\\*.*");
CString filename;
BOOL bfind = filefinder.FindFile(strSearchPath);
CString SourcePath, DisPath;
while (bfind)
{
bfind = filefinder.FindNextFile();
if (filefinder.IsDots() || filefinder.IsSystem() || filefinder.IsHidde()||filefinder.IsDirectory())
continue;
filename = filefinder.GetFileName();//获取文件名字
SourcePath = strSourcePath + "\\" + filename; //要复制文件名
DisPath = strDesPath + "\\" + filename; //复制后的文件名
::CopyFile(SourcePath,DisPath,FALSE); //调用系统复制函数
}
2012-04-17
int和CString相互转化
Int转化成Cstring
CString cStr;
int nCount=999;
cStr.Format(_T("%d"),cCount);
CSTRING如何转成INT
网上的介绍都是用atoi函数,但是CString 内部存储的是wchar_t 类型的字符,每个字符占两个字节,atoi的参数是char*,每个字符占一个字节 ,如果强制转换成char*,由于高位字节是空,所以就转成了只有第一个字符的串,这样是不对的.应该用_wtoi函数,这个函数的参数是wchar_t*,示例如下:
CString str("123");
int num = _wtoi(str);
同样,也有_wtof(),_wtol()等函数可供将CString 转成不同的数值类型.
2012-04-17
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人