What is the simplest way to get the directory that a file is in? I\'m using this to find the working directory.
string filename = \"C:\\MyDirectory\\MyFile.b
As Question is old but I would like to add an answer so that it will helpful for others.
in Visual c++ you can use CString or char array also
CString filename = _T("C:\\MyDirectory\\MyFile.bat");
PathRemoveFileSpec(filename);
OUTPUT:
C:\MyDirectory
Include Shlwapi.h in your header files.
MSDN LINK here you can check example.