# How can I get direction or link of file in computer

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

file.open("../Engine/data/model.obj");


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.

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.

• 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/… – 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);
}


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