using namespace std;
ofstream myfile;
//myfile.open ("Z:\\ABC.TXT"); // fails Z: is a network drive
//myfile.open("C:\\Temp\\ABC.TXT"); // OK
//myfile.open("Z:\\NETWORK\\02-010E.CHS"); // fails Z:\Network is a network folder
if (myfile.is_open())
cout << "file is open" << endl;
else
cout << "file fails to open" << endl;
myfile.close();
Câu hỏi: Dường như ofstream.open
không hỗ trợ để mở tệp trên ổ đĩa mạng. Có cách nào đơn giản để giải quyết vấn đề này không?Cách truy cập tệp mạng?
Hãy thử 'std :: cout << std :: strerror (errno)' và xem những gì nó in ([tham khảo] (http://en.cppreference.com/w/cpp/string/byte/strerror)) . –
Không có tệp hoặc thư mục nào như vậy – q0987