简体   繁体   English

在Windows 8中使用C ++重命名文件

[英]Rename file on Windows 8 in C++

I am working on a Windows 8 machine running a C++ project. 我在运行C ++项目的Windows 8计算机上工作。 I sometimes receive a -1 response for the following line of code. 对于以下代码行,有时我会收到-1响应。 Is there another way to rename a file that will work? 是否有其他方法可以重命名文件?

    std::rename(oldFileName, newFileName);

I wasn't able to receive output from perror but I was able to figure out the solution. 我无法接收到来自perror的输出,但是我能够找出解决方案。

Last week there was a Windows updated (unknown to me because it was not my computer) that put more restrictions on the C drive. 上周有一个Windows更新(对我来说是未知的,因为那不是我的计算机),它对C驱动器施加了更多限制。 My oldFileName was located in the C drive and because of those restrictions, it would not rename the file. 我的oldFileName位于C驱动器中,由于这些限制,它不会重命名该文件。 I had to move the file location out of the C drive. 我不得不将文件位置移出C驱动器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM