How to get full path of sepcied file
-
Hi, I want to get the full path of specified path. I use following function as DWORD dwRet = 0; TCHAR szPath[500]; LPTSTR lpszFilePart; dwRet = GetFullPathName(_T("MyFile.txt"), sizeof(szPath) / sizeof(TCHAR), szPath, &lpszFilePart); In above function i get path in szPath variable. but this path is always shows path in desktop, thought myfile.txt is placed in D: drive in othere folder.Also if file name not exists, though it show path with specied file name. How can I get full path of file by giving file name as input parameter. Thanks Abm
-
Hi, I want to get the full path of specified path. I use following function as DWORD dwRet = 0; TCHAR szPath[500]; LPTSTR lpszFilePart; dwRet = GetFullPathName(_T("MyFile.txt"), sizeof(szPath) / sizeof(TCHAR), szPath, &lpszFilePart); In above function i get path in szPath variable. but this path is always shows path in desktop, thought myfile.txt is placed in D: drive in othere folder.Also if file name not exists, though it show path with specied file name. How can I get full path of file by giving file name as input parameter. Thanks Abm
If you read the MSDN documentation, under Remarks is says: GetFullPathName merges the name of the current drive and directory with a specified file name to determine the full path and file name of a specified file...This function does not verify that the resulting path and file name are valid, or that they see an existing file on the associated volume. I think you will find that the current directory is set to the desktop which is why you are getting the result you are. If you want a full path to a different directory you will have to change the working directory.