wsave_path[save_path.length()] = '\0'; ? Since toWCharArray does not return a NULL terminated array?