0

I'm looking for function that open window explorer and get file the user selected. I knew how to open window explorer to this my question, but I was asking the wrong question. I want to enable read to the user selects a file.

While trying to search, I found OpenFileDialog(). But this function looks like need GUI. Am I right? (My program runs only console)

How can I open windows explorer on the console and get the file from the user?

I'm a beginner of C. So my question may seem ridiculously easy. But if you give me the answer I really appreciate it. Thanks :)

Community
  • 1
  • 1
Soyeon Kim
  • 608
  • 7
  • 34
  • What exactly do you mean by 'get file user selected'? Do you want to open windows explorer and then open the file? – moffeltje Mar 24 '15 at 10:28
  • @moffeltje Yes, I do. You're right :) I'm Korean, so I don't know the explanation in English well. Thanks – Soyeon Kim Mar 24 '15 at 23:58

2 Answers2

0

You are looking for the GetOpenFileName function. (OpenFileDialog is for .NET applications; if you are using C then you are not using .NET).

According to MSDN, this has been superseded by the Common Item Dialog system, but that system is much more complicated, requires COM and isn't necessary if you are only selecting files. GetOpenFileName will still work for the foreseeable future.

user253751
  • 57,427
  • 7
  • 48
  • 90
0

To open Windows explorer:

system("start \"\" \"c:\\program files\"");

To open a specific file:

system("start \"\" \"c:\\program files\\file.txt\"");
moffeltje
  • 4,521
  • 4
  • 33
  • 57