I want to import an .obj file in my Engine or open some files : To do that I write a link or direction of that file in my computer. Like this


But I dont want to write a link every time. In most application if you want to import or open a file you click on import or open and it opens a window where you search that file in your computer and click open.
Here is a picture to see what I am about.

enter image description here

How it is done?. How can i write a c++ program to get link of a file like here?.
Is there any windows libraries or API's to creat something like this.

  • \$\begingroup\$ Side note: please, please, please do not make your game Windows exclusive. \$\endgroup\$ – Lolums Nov 29 '15 at 14:11
  • \$\begingroup\$ The question is also not very clear. What exactly are you trying to do? If you want to present the user with a file choosing dialogue, you should check this out: stackoverflow.com/questions/6145910/… \$\endgroup\$ – Lolums Nov 29 '15 at 14:13

You can do the following: (if I understand you correctly)

-E.g get the path of your applications root folder

std::string rootDir = "";

char buffer[MAX_PATH];
GetModuleFileName(NULL, buffer, MAX_PATH);
std::string::size_type pos = std::string(buffer).find_last_of("\\/");
std::string pathstr = std::string(buffer).substr(0,pos);
rootDir = pathstr.c_str(); // e.g = "C:\xx\Desktop\abc"

then use it like:

file.Open(path + "\\data\\Model.obj");

or, so you can do it more simplier for you:

File fileOpen(std::string filePath)
    return file.Open(path + filePath);

If you need to know how to make a FileDialog, google it please.. There are soo much sources.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.