//遍历文件夹int FindFile(char* lpPath)
{char szFind[1000] = {0};WIN32_FIND_DATA FindFileData;strcpy(szFind,lpPath);strcat(szFind,"\\*.*");HANDLE hFind = ::FindFirstFile(szFind,&FindFileData);if (INVALID_HANDLE_VALUE==hFind){return -8;//没有文件}while(1){if (FindFileData.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY){if (FindFileData.cFileName[0]!='.'){char szfile[500] = {0};strcpy(szfile,lpPath);strcat(szfile,"\\");strcat(szfile,FindFileData.cFileName);FindFile(szfile);}}else{//文件名+路径char tmpupload[1000] = {0};strcpy(tmpupload,lpPath);strcat(tmpupload,"\\");strcat(tmpupload,FindFileData.cFileName);//下载}if (!FindNextFile(hFind,&FindFileData)){break;}}FindClose(hFind);//用完记得关闭return 0;}
int GetFileNameExtension(char*filename,char*Extension)//获取文件名后缀
{CString tmp;tmp = filename;tmp.MakeLower();//转成小写char fileTmp[1000] = {0};if (tmp.GetLength()>1000){return -27;}strcpy(fileTmp,tmp.GetBuffer());char*tmpname = strrchr(fileTmp,'.');if (tmpname==NULL){return -1;//执行失败}if (strlen(tmpname)>10){return -27;}strcpy(Extension,tmpname+1);return 0;}
本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!