wstring path = L"C:\\Users\\oneworduser\\Desktop\\trash";
LPCWSTR origin = (path + L"\\" + files.at(i)).wstring::c_str();
LPCWSTR destination = (path + L"\\" + extensions.at(i) + L"\\" + files.at(i)).wstring::c_str();
//move file
BOOL b = MoveFileW(origin, destination);
MoveFileWはfalseを返します。
files.at(i)は、現在のファイルの名前であるwstring
です。
extensions.at(i)は、の後に続くサブストリングです。 files.at(i)内にあります。たとえば、
files.at(0)
がmytext.txt
の場合、extensions.at(0)
はtxt
です。 MoveFileWはfalseを返します。GetLastError()
の場合、エラー123(ERROR_INVALID_NAME
)が返されます。
ファイルを移動できないのはなぜですか?C++でMoveFileを使用してファイルを移動しようとするとERROR_INVALID_NAMEが返される
ありがとうございます。これがなければこのプログラムは終了しませんでした。 – Carlos