It's not at all clear what you are doing, but why the wcstombs_s? Just use _wfopen_s, or better yet, open a CFile and avoid all the string conversion nonsense; fopen_s is going to have to convert it back to wide char before calling the API internally anyway. Also, the windows API call to MoveFile is probably a better way to rename files in MFC and _UNICODE.