How to open any file? (Just to open and not to read, what would the user select to open it)


I need to open a txt file which is NOT in the same folder as the project. Can you write in detail how to do this?

Closed due to the fact that the essence of the question is incomprehensible by the participants Vladimir Martianov , Abyx , Kromster , Harry , vp_arth 15 Nov '17 at 17:40 .

Try to write more detailed questions. To get an answer, explain what exactly you see the problem, how to reproduce it, what you want to get as a result, etc. Give an example that clearly demonstrates the problem. If the question can be reformulated according to the rules set out in the certificate , edit it .

  • 2
    Opening a file is invisible to the user. You obviously want to not open the file, but something else. But that is not clear. Complete the question. - Vladimir Martyanov
  • system(файл) can? - Vladimir Gamalyan
  • If you need WinAPI OpenFileDialog, then try GetOpenFileName - vp_arth

2 answers 2

To open a txt file that is NOT in the same folder as the project, you must specify the full path to this file in the file name. Or there is a second option - to change the current directory and open the file without the full path, but after that it is strongly recommended to return the current directory back. :-)

UPD1:

And yet - the full path can be specified either absolute, or relative to the current directory. :-)

     ShellExecute(0, 0, "notepad.exe", полный_путь_и_имя, 0, SW_SHOW); 
    • @ 0xdb, why not contained? - Qwertiy
    • @Qwertiy I agree, it is too short to immediately understand, it was necessary to skip. - 0xdb