看板 C_and_CPP 關於我們 聯絡資訊
我想將一個選定的檔案move到指定的路徑下 我是使用MoveFile()這個function int result; char cNewPathName[256]; char cOldPathName[256]; DWORD nBufferLength = 200; // size of directory buffer TCHAR CurrentPath[200]; memset( CurrentPath, NULL, sizeof(CurrentPath) ); memset( cNewPathName, NULL, sizeof(cNewPathName) ); memset( cOldPathName, NULL, sizeof(cOldPathName) ); printf("Enter target path >"); gets(cNewPathName); GetCurrentDirectory(nBufferLength, CurrentPath); sprintf(cOldPathName, "%s\\%s.%s\0", CurrentPath, FilesName, FilesExt); result = MoveFile(cOldPathName, cNewPathName); 不過一直失敗 result都收到0的回傳值 麻煩版友幫我診斷一下 Orz 謝謝 -- ╔╮ ╭═╦╮╭═╦╗╮ ╮╔══╮╭═╦╮╮ ╔╮╔══╮╭══╮ ╠╣ ╠═╬╣╭╬╩╯╰╦╦╯╠═╦╮║ ╠╣║║╠╣╠╣ ╰═╦╮ ╠╣ ╭║ ╠╣║╰╔╗ ╠╣ ║ ╠╣║ ╠╣║╰╠╣║╰╔╗║ ╠╣ ╰╩═╯╰ ╰╝╚═╩╯ ╰╝ ╚═╩╯╰═╩╯╰ ╰╝╚═╩╯╰═╩╯ -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 218.211.0.80
VictorTom:""裡應該不用特別加'\0', 另外, 用GetLastError()檢查為 11/11 10:10
VictorTom:什麼失敗看看@_@" 11/11 10:11
lazybones:對喔...有GetLastError()...大感謝!!!<(_ _)> 11/11 10:33
aecho:都用TCHAR了,為什麼還要用char呢? 11/11 12:58
VictorTom:對吼, 都忘了這種API要注意TCHAR的問題....XD 11/11 13:01
lazybones:嗯 謝謝!! 11/11 13:08