I have the following problem, that should be well-known, but I have fai开发者_C百科led to google anything relevant.
I have a C# project, some of its performance-critical parts are supposed to be inside C++ DLL. In DLL I am trying to read some file using std::fstream
. The problem is that it fails to read this file and pretends that there is no file at all (though I'm using the full path to it).
The question is the following: is this problem well-known? Probably I'm doing something wrong, in the other case what are possible workarounds?
This is the extract of my code:
fstream input("c:\\path\\file.txt");
if (!input) throw runtime_error("file not found");
UPD: FILE* seems to work. It is very weird.
Did you forget to properly quote backslashes? Shouldn't it be:
fstream input("c:\\path\\file.txt");
if (!input) throw runtime_error("file not found");
on top of that, I would avoid using ifstream if that code is performance sensitive.
精彩评论