System.IO.IOException: Процесс не может получить доступ к файлу "test.txt", так как этот файл используется другим процессом

fstream f(legitfiles.c_str(), fstream::in );
string s;
while(getline(f, s)){
    size_t space_pos = s.rfind(" ") + 1;

    cout << s.substr(space_pos) << endl;
    ofstream results("results.c_str()");
    results << s.substr(space_pos) << endl;
    results.close();

}
cout << s << endl;
f.close();

Ответы (0 шт):