// 2バイト文字のファイル名では「¥」を含む場合があるので //デリミタの「¥」か2バイト文字用の「¥」かを判定 char *fndYen(const char *str) { char *ret = NULL; for (char *cp = strchr(str, '\\'); cp != NULL; cp = strchr(cp, '\\')){ if (_ismbstrail((const unsigned char *)str, (const unsigned char *)cp) != 0){ ++cp; continue; } return cp; } return ret; } BOOL CopyFileDir(LPCTSTR lpExistingFileName, LPCTSTR lpNewFileName, BOOL bFailIfExists) { char buf[MAX_PATH]; strcpy(buf, lpNewFileName); for(char *p = fndYen(buf); p != NULL; p = fndYen(p+1)){ *p = '\0'; int st = GetFileAttributes(buf); if (st < 0){ CreateDirectory(buf, NULL); } *p = '\\'; } return CopyFile(lpExistingFileName, lpNewFileName, bFailIfExists); }