std::ifstream无法打开c:program files(x86)下的文件
std::ifstream failed to open file under c:program files(x86)
我有管理权限,并尝试在windows上打开c:\program files(x86)下的文件。std::ifstream无法打开,错误编号为2。如果我将同一个文件复制到其他位置,它可以正常工作。
#include <iostream>
#include <cerrno>
#include <string>
#include <fstream>
int main()
{
std::ifstream ifs1("C:\Program Files(x86)\somefile.html");
if (ifs1.is_open())
{
std::cout << "File openedn";
}
else
{
std::cout << "File open failed. error number = " << errno << std::endl;
}
return 0;
}
是因为权限问题吗?
可能是因为这个:
"C:\Program Files(x86)\somefile.html"
实际上应该是:
"C:\Program Files (x86)\somefile.html"
你只是漏掉了一个空格。
相关文章:
- .cpp和.h文件中的模板专用化声明
- 为什么两个不同的未命名名称空间可以共存于一个cpp文件中
- 文本文件中的单词链表
- CMake-按正确顺序将项目与C运行时对象文件链接
- 使用新行和不使用新行读取文件
- 在C++程序中输入的文本文件将不起作用,除非文本被复制和粘贴
- 挂起和取消挂起一个文件DLL
- 如何确定我已使用非编码文件到达 EOF?
- 命名空间中具有.h和.cpp文件的类
- 如何使用ndk-build.cmd构建Android.so文件
- 从包含m行的文件中提取n行,必要时(惰性地)重复该文件
- 读取文件并输入到矢量中
- 在C++中查找文件
- 如果给定正确的运行时库,x86 可执行文件是否可以在任何 x86 平台上运行
- VS2012 如何将 C# 的 AnyCPU 配置的输出目录设置为各自解决方案配置的 x86 和 x64 文件夹?
- 错误0xc000007b:试图在没有VS的计算机上运行编译为Release x86的C++.exe文件
- 有一个简单的程序文件/程序文件(x86)指令的c++在windows
- 复制到程序文件(x86)时无法执行我的DLL
- Qt5静态构建无法打开输入文件"/SDK/lib/x86.obj"
- std::ifstream无法打开c:program files(x86)下的文件