How to check if a file exists and is readable in C++?

前端 未结 8 1447
时光说笑
时光说笑 2020-12-13 12:19

I\'ve got a fstream my_file(\"test.txt\"), but I don\'t know if test.txt exists. In case it exists, I would like to know if I can read it, too. How to do that?

I

8条回答
  •  囚心锁ツ
    2020-12-13 12:55

    Concerning the use of fstat in windows, I am not sure if it is what you want. From Microsoft the file must be already open. Stat should work for you.

提交回复
热议问题