本文代码实现的功能为:
读取images 文件夹下全部格式为.jpg格式的图片名称,并将名称显示出来。
以下为代码
getFileContents.h
#ifndef GETFILECONTENTS_H
#define GETFILECONTENTS_H
#include<string>
#include<vector>
using namespace std;
typedef vector<string> filelists;
filelists getImagePathes(const char* path,const char* extension);
#endif
getFileContents.cpp
#include "getFileContents.h"
#include<Windows.h>
using namespace std;
#define LEN 1024
wstring s2ws(const std::string& s)
{
int len;
int slength = (int)s.length() + 1;
len = MultiByteToWideChar(CP_ACP, 0, s.c_str(), slength, 0, 0);
wchar_t* buf = new wchar_t[len];
MultiByteToWideChar(CP_ACP, 0, s.c_str(), slength, buf, len);
std::wstring r(buf);
delete[] buf;
return r.c_str();
}
// wchar_t to string
void Wchar_tToString(std::string& szDst,