This code at least works: string directory_path(argv[1]); path p(directory_path); ostringstream component; string lastComponent; for (path::iterator it = p.begin(); it != p.end(); it++) { component.str(""); // Hack, to be replaced by better way component << *it; // to grab `*it' in a string lastComponent = component.str(); } lastComponent = lastComponent.substr(1, lastComponent.size()-2); According to the documentation examples, the item pointed to by `*it' is of the following type: path::iterator::value_type is path::string_type, and iteration treats path as a container of filenames. I tried to capture `*it' in a string and in a string_type but the compiler does not like the '=' operator. TIA, -RFH