【发布时间】:2012-04-10 01:03:36
【问题描述】:
我有一个尝试移动文件的小应用程序。
这是最低代码:
#include <windows.h>
int main()
{
MoveFile("C:\\test.txt", "C:\\folder\\test.txt");
// Here I use GetLastError() to get last error code witch is 2 and I can't find what mean;
return 0;
}
重要提示:此错误出现在 Windows 7 上,但在 win XP 上运行,文件被移动!
【问题讨论】:
-
我猜
C:\folder不存在或C:\test.txt不存在。在 Windows 7 上,您需要管理员权限才能在资源管理器中实际写入C:` so just because you see atest.txt` 并不意味着它实际上位于该位置。但我不知道MoveFile是否知道这种每用户虚拟存储机制...