Hi All
using the openfile dialog I get the full path to my file which is ok but I need to strip it down and remove the drive and initial dir folders from it the code I have so far
OPENFILENAME ofn; // common dialog box structure
char szFile[260]; // buffer for file name
HWND hwnd = hwnd;// owner window
HANDLE hf; // file handle
// Initialize OPENFILENAME
ZeroMemory(&ofn, sizeof(ofn));
ofn.lStructSize = sizeof(ofn);
ofn.hwndOwner = hwnd;
ofn.lpstrFile = szFile;
// Set lpstrFile[0] to '\0' so that GetOpenFileName does not
// use the contents of szFile to initialize itself.
ofn.lpstrFile[0] = '\0';
ofn.nMaxFile = sizeof(szFile);
ofn.lpstrFilter = "*.dds";
ofn.nFilterIndex = 1;
ofn.lpstrFileTitle = NULL;
ofn.nMaxFileTitle = 0;
ofn.lpstrInitialDir = MyArtDirectory;
ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
// Display the Open dialog box.
if (GetOpenFileName(&ofn) == TRUE)
{
hf = CreateFile(ofn.lpstrFile,
GENERIC_READ,
0,
(LPSECURITY_ATTRIBUTES)NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
(HANDLE)NULL);
//TO DO STRIP THE baseDIR FROM THE PATH SO WE CAN APPEND THE THEATERS.1ST FILE
char real_filename[MAX_PATH] = { 0 };
strncpy(real_filename, szFile + ofn.nFileOffset, ofn.nFileExtension - 1 - ofn.nFileOffset);
MessageBox(NULL, real_filename, "File Chosen", MB_OK); //check we have got the string for the path
}
I have tried some version the above will give me just the filename cool but I need also just some parts of the path ie everything except for the ofn.lpstrInitialDir as it point to the initial dir I need to strip that from the szFile string is this possible ?
so for example instaed of d:\apps\myapp\art\dir1\dir2\my.dds I would like just to have dir1\dir2\my.dds
any help greatly appreciated