作者: veve178 時間: 2008-11-6 16:38 標題: C++ system問題
係c++用system("del %userprofile%\\Local Settings\\Temp\\a.txt"); 出問題,
彈系統找不到指定的路徑
如果整個.bat寫del %userprofile%\Local Settings\Temp\a.txt 就冇事,可以正常delete..
到底咩問題呢,有冇得解決
作者: thinkpanda 時間: 2008-11-6 16:50
原帖由 veve178 於 2008-11-6 16:38 發表
係c++用system("del %userprofile%\\Local Settings\\Temp\\a.txt"); 出問題,
彈系統找不到指定的路徑
如果整個.bat寫del %userprofile%\Local Settings\Temp\a.txt 就冇事,可以正常delete..
到底咩問題呢,有冇得解決
點解唔用DeleteFile 呢?
system function 恐怕唔認得%userprofile% 呢D environment variable. 正規既方法應該係用Win32 API GetFolderPath
如果你一定要用environment variable, 用Win32 API GetEnvironmentVariable.
作者: veve178 時間: 2008-11-6 17:28
原帖由 thinkpanda 於 2008-11-6 16:50 發表
點解唔用DeleteFile 呢?
system function 恐怕唔認得%userprofile% 呢D environment variable. 正規既方法應該係用Win32 API GetFolderPath
如果你一定要用environment variable, 用Win32 API GetEnvironmentVariable.
我唔用%userprofile%都係唔得喎,直接指向個file都係咁
作者: freewave 時間: 2008-11-6 19:15
you should code with the following style:
system("del \"%userprofile%\\Local Settings\\Temp\\a.txt\"");
[ 本帖最後由 freewave 於 2008-11-6 19:16 編輯 ]

