Comment obtenir le nom de chemin complet en C ++
-
10-10-2019 - |
Question
Y at-il une fonction qui renvoie le nom de chemin complet pour tout fichier entré est?
Je pense à quelque chose comme:
LPCSTR path = "foo.bar"
LPCSTR fullPath = FullyQualifiedPath(path);
//fullPath now equals C:\path\to\foo.bar
Merci
La solution
Dans Win32, appelez le GetFullPathName
fonction.
Autres conseils
Utiliser boost :: système de fichiers http://www.boost.org/doc /libs/1_44_0/libs/filesystem/v2/doc/index.htm
#include <iostream>
#include <boost/filesystem.hpp>
int main()
{
boost::filesystem::path p = boost::filesystem::complete("foo.bar");
std::cout << p;
}
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow