Original Post
i have tryed to write a general file opening method but its not working
so i can do GetFileName(fileName, "please enter an xml file" , "xml");
but it really is not working , can any one tell me were i am going wrong
bool GetFileName(string& file, string Message, string fileExtention)
{
char fileName[MAX_PATH] = "";
OPENFILENAME openFile;
ZeroMemory( &openFile, sizeof(OPENFILENAME) );
openFile.lStructSize = sizeof(OPENFILENAME);
openFile.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY ;
string messageString = "All\0*.*\0" + fileExtention + "\0*." + fileExtention + "\0";
openFile.lpstrFilter = messageString.c_str();
openFile.lpstrDefExt = fileExtention.c_str();
openFile.lpstrFile = fileName;
openFile.nMaxFile = MAX_PATH;
// Open file as a text stream
if (!GetOpenFileName(&openFile)) return false;
file = fileName;
return true;
}
so i can do GetFileName(fileName, "please enter an xml file" , "xml");
but it really is not working , can any one tell me were i am going wrong