[問題] MoveFile的問題

看板C_and_CPP作者 (懶)時間16年前 (2009/11/11 10:04), 編輯推噓3(303)
留言6則, 3人參與, 最新討論串1/1
我想將一個選定的檔案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

11/11 10:10, , 1F
""裡應該不用特別加'\0', 另外, 用GetLastError()檢查為
11/11 10:10, 1F

11/11 10:11, , 2F
什麼失敗看看@_@"
11/11 10:11, 2F

11/11 10:33, , 3F
對喔...有GetLastError()...大感謝!!!<(_ _)>
11/11 10:33, 3F

11/11 12:58, , 4F
都用TCHAR了,為什麼還要用char呢?
11/11 12:58, 4F

11/11 13:01, , 5F
對吼, 都忘了這種API要注意TCHAR的問題....XD
11/11 13:01, 5F

11/11 13:08, , 6F
嗯 謝謝!!
11/11 13:08, 6F
文章代碼(AID): #1A-XkfzC (C_and_CPP)