
std::string tempDirectory = "./test/*";WIN32_FIND_DATA directoryHandle;memset(&directoryHandle,sizeof(WIN32_FIND_DATA));//perhaps redundant???std::wstring wIDeString = std::wstring(tempDirectory.begin(),tempDirectory.end());LPCWSTR directoryPath = wIDeString.c_str();//iterate over all filesHANDLE handle = FindFirstfile(directoryPath,&directoryHandle);while(INVALID_HANDLE_VALUE != handle){ //skip non-files if (!(directoryHandle.DWfileAttributes & file_ATTRIBUTE_DIRECTORY)) { //convert from WCHAR to std::string size_t size = wcslen(directoryHandle.cfilename); char * buffer = new char [2 * size + 2]; wcstombs(buffer,directoryHandle.cfilename,2 * size + 2); std::string file(buffer); delete [] buffer; std::cout << file; } if(FALSE == FindNextfile(handle,&directoryHandle)) break;}//close the handleFindClose(handle); 它在相对目录./test/*中打印每个文件的名称.
有没有办法确定这个目录的绝对路径,就像linux上的realpath()一样,不涉及像BOOST这样的第三方库?我想打印每个文件的绝对路径.
解决方法 请参阅GetFullPathName功能. 总结 以上是内存溢出为你收集整理的c – WIN32_FIND_DATA – 获取绝对路径全部内容,希望文章能够帮你解决c – WIN32_FIND_DATA – 获取绝对路径所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)