Click here to Skip to main content
15,860,972 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Need a suggestion in searching a file Pin
Richard MacCutchan12-Dec-15 6:23
mveRichard MacCutchan12-Dec-15 6:23 
QuestionRe: Need a suggestion in searching a file Pin
VISWESWARAN199812-Dec-15 7:29
professionalVISWESWARAN199812-Dec-15 7:29 
AnswerRe: Need a suggestion in searching a file Pin
Richard MacCutchan12-Dec-15 8:32
mveRichard MacCutchan12-Dec-15 8:32 
PraiseRe: Need a suggestion in searching a file Pin
VISWESWARAN199812-Dec-15 9:13
professionalVISWESWARAN199812-Dec-15 9:13 
QuestionRe: Need a suggestion in searching a file Pin
David Crow12-Dec-15 15:58
David Crow12-Dec-15 15:58 
PraiseRe: Need a suggestion in searching a file Pin
VISWESWARAN199813-Dec-15 4:23
professionalVISWESWARAN199813-Dec-15 4:23 
GeneralRe: Need a suggestion in searching a file Pin
Richard MacCutchan13-Dec-15 5:39
mveRichard MacCutchan13-Dec-15 5:39 
GeneralRe: Need a suggestion in searching a file Pin
VISWESWARAN199821-Mar-16 5:02
professionalVISWESWARAN199821-Mar-16 5:02 
Sir, I have tried a lot and finally figured out something. It is by searching for a specific file with MD5 hashes. Since, I want to search for a specific file through the whole drive.

Here is my try

C++
inline std::string narrow(std::wstring const& text)
{
	std::locale const loc("");
	wchar_t const* from = text.c_str();
	std::size_t const len = text.size();
	std::vector<char> buffer(len + 1);
	std::use_facet<std::ctype<wchar_t> >(loc).narrow(from, from + len, '_', &buffer[0]);
	return std::string(&buffer[0], &buffer[len]);
}

void _tmain(int argc, TCHAR *argv[])
{

	HANDLE hFind;
	WIN32_FIND_DATA data;

	std::string path = "C:\\";
	std::string fileName = "";
	wchar_t* file = L"C:\\*";
	hFind = FindFirstFile(file, &data);
	if (hFind != INVALID_HANDLE_VALUE) {
		do {

			fileName = narrow(data.cFileName);

			if (fileName.compare(".") == 0)
				continue;
			if (fileName.compare("..") == 0)
				continue;

			cout << "FileName: " << fileName << " MD5 hash: ";
			// prepare filename
			std::string finalFile = path + fileName;
			char *cstr = new char[finalFile.length() + 1];
			strcpy(cstr, finalFile.c_str());

			//calc the md5 hash
			char **temp = CALL_MD5_Function(cstr);
			cout << temp;
			cout <<endl << endl;
		} while (FindNextFile(hFind, &data));
		FindClose(hFind);
	}
}


I don't know how to iterate if I found a directory, in here

C++
if (fileName.compare(".") == 0)
				continue;
			if (fileName.compare("..") == 0)
				continue;


I used continue statement to break the skip the operation since I am unsure. Could you please suggest me some ways to do it?

Thank you sir for your kind help
GeneralRe: Need a suggestion in searching a file Pin
Richard MacCutchan21-Mar-16 22:22
mveRichard MacCutchan21-Mar-16 22:22 
PraiseRe: Need a suggestion in searching a file Pin
VISWESWARAN199824-Mar-16 6:37
professionalVISWESWARAN199824-Mar-16 6:37 
QuestionAre they the same? The button and MFC button control Pin
Cptr11-Dec-15 2:44
Cptr11-Dec-15 2:44 
AnswerRe: Are they the same? The button and MFC button control Pin
Richard MacCutchan11-Dec-15 4:49
mveRichard MacCutchan11-Dec-15 4:49 
QuestionAfter including #include <atlbase.h> I am getting error C2632 Pin
ptr_Electron10-Dec-15 22:41
ptr_Electron10-Dec-15 22:41 
AnswerRe: After including #include <atlbase.h> I am getting error C2632 Pin
Jochen Arndt10-Dec-15 23:22
professionalJochen Arndt10-Dec-15 23:22 
GeneralRe: After including #include <atlbase.h> I am getting error C2632 Pin
ptr_Electron11-Dec-15 3:34
ptr_Electron11-Dec-15 3:34 
GeneralRe: After including #include <atlbase.h> I am getting error C2632 Pin
Jochen Arndt11-Dec-15 4:07
professionalJochen Arndt11-Dec-15 4:07 
GeneralRe: After including #include <atlbase.h> I am getting error C2632 Pin
ptr_Electron11-Dec-15 18:52
ptr_Electron11-Dec-15 18:52 
Questionproblem in solving "C4996" error Pin
VISWESWARAN199810-Dec-15 20:48
professionalVISWESWARAN199810-Dec-15 20:48 
AnswerRe: problem in solving "C4996" error Pin
Jochen Arndt10-Dec-15 21:16
professionalJochen Arndt10-Dec-15 21:16 
PraiseRe: problem in solving "C4996" error Pin
VISWESWARAN199811-Dec-15 0:39
professionalVISWESWARAN199811-Dec-15 0:39 
AnswerRe: problem in solving "C4996" error Pin
Richard MacCutchan10-Dec-15 21:57
mveRichard MacCutchan10-Dec-15 21:57 
PraiseRe: problem in solving "C4996" error Pin
VISWESWARAN199811-Dec-15 0:40
professionalVISWESWARAN199811-Dec-15 0:40 
QuestionPassing double pointer to function Pin
elelont29-Dec-15 21:49
elelont29-Dec-15 21:49 
AnswerRe: Passing double pointer to function Pin
Richard MacCutchan9-Dec-15 22:29
mveRichard MacCutchan9-Dec-15 22:29 
QuestionResize a Dialog Box (MDI-Application) Pin
Schehaider_Aymen7-Dec-15 23:05
Schehaider_Aymen7-Dec-15 23:05 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.