std::ifstream unable to open file

Hello guys!

I have some part in my QT Application:
1
2
3
4
5
6
7
8
9
10
11
12
    //Part 1:
    // get file length
    std::ifstream file( path.toUtf8().constData() , std::ios::binary | std::ios::ate);
    size_t file_length = file.tellg();
    file.close();

    //Part 2:
    std::ifstream read_file;
    read_file.open(path.toUtf8().constData());
    //read_file.open(current_file_path);

    if(read_file.is_open()) ...


So in part one everything is good. File is opened and the length of id obtained.
But, the part two is have some problem. Its can not to open file and is_open() return false. And "fail" bit is set.

Thing is, I deployed this app and on my computer everything is work fine. But on another PC - nothing.

I have checked rights to open testing file and right for execution of application. Even tried to do all stuff under Administrator account.

Nothing. Maybe you can help me with it. It is kind of weird behavior.

Thank you in advance.

P.S. Developing platform Windows 7 x64, Qt Creator 3.0.1, QT version 5.2.1, compiler MSVC 2010, 32 bit
Last edited on
Maybe there is something that overwrites your "path" variable. You should print the variable to see if it is exactly what is expected.
I do not think so.
There is some more several files. The are not opened as well.

So with path everything is good. Besides path it is a parameter of function and there is no operations to change it.

It is look like application can not open files in std::ios::in mode. O do not know.
Topic archived. No new replies allowed.