Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/161.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 无法使用函数Cfile在MFC中读取文件中的内容?_C++_Mfc_Cfile - Fatal编程技术网

C++ 无法使用函数Cfile在MFC中读取文件中的内容?

C++ 无法使用函数Cfile在MFC中读取文件中的内容?,c++,mfc,cfile,C++,Mfc,Cfile,如果我在文件中手动写入内容,我将无法读取文件中的内容…如果存在内容,我将能够读取内容…但是如果我在文件中手动写入内容并尝试读取,我将无法读取我编辑的内容..请检查下面我用于读取的代码 CFile file; if(file.open("C:\\users\\rakesh\\Desktop\\myText.txt",CFile::modeRead)) { return false; } TCHAR buffer[50];//say content is small file.read(buffe

如果我在文件中手动写入内容,我将无法读取文件中的内容…如果存在内容,我将能够读取内容…但是如果我在文件中手动写入内容并尝试读取,我将无法读取我编辑的内容..请检查下面我用于读取的代码

CFile file;
if(file.open("C:\\users\\rakesh\\Desktop\\myText.txt",CFile::modeRead))
{ 
return false;
}
TCHAR buffer[50];//say content is small
file.read(buffer,50);
file.close();

看起来像是unicode问题。我猜您的项目设置为使用unicode,但您的编辑器编写ascii。

我实际上尝试了检查,是的,您所说的是正确的。.它是以字符形式读取的,但不是以TCHAR形式读取的…因此,我如何解决问题…如果您需要读取的文件是unicode,我将非常感谢您的帮助,您只需使用能够读写unicode的编辑器。否则,请将项目设置设置为!unicode并使用char而不是TCHAR。