我在 Windows 8 上使用 MFC。当我得到 Temp
路径时,它包含指向不同用户帐户的路径:
C:\Users\AACE~1\AppData\Temp
写入文件的权限已关闭,CFile
失败。我的帐户是:
C:\Users\Dmitry
我在我的帐户下调试和启动应用程序。问题是什么?此外,我在 Windows 8 上运行时只有一个用户帐户。
最佳答案
documentation对于这个函数描述了它是如何工作的:
The GetTempPath function checks for the existence of environment variables in the following order and uses the first path found:
- The path specified by the TMP environment variable.
- The path specified by the TEMP environment variable.
- The path specified by the USERPROFILE environment variable.
- The Windows directory.
因此,可能的原因是您的环境配置错误。检查 TMP
和 TEMP
环境变量的值。
关于c++ - GetTempPath 显示与当前不同的用户,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27018500/