How to get file's itself directory without filename?

1
2
3
4
5
6
7
8
9
10
int _tmain(int argc, _TCHAR* argv[])
{
	TCHAR buf0[MAX_PATH];
	GetModuleFileName(0, buf0, MAX_PATH);

	TCHAR installer[_MAX_PATH];
	_tcscpy(installer, buf0);
	_tcscat(installer, _T("\\test"));
	_mkdir(installer);
}
I'm trying to get filename (directory) of file and make its subdirectory. But if my file's extension is .exe I would like to delete 8 characters to fully delete "test.exe" text in installer and then join //test (_tcscat(installer, _T("\\test"));) Is it possible. Maybe it's possible to get folder name of that path without filename?
Maybe it's possible to get folder name of that path without filename?


1
2
std::filesystem::path pathToFile(buf0);
pathToFile.remove_filename();

pathToFile is now the path, without the filename
Thanks, solved by using boost::filesystem::path
Join us in C++17 :)
C++17 != Visual Studio 2017
Topic archived. No new replies allowed.