Hi all,
I am presently working with folder and would like to find out the number of files in that particular directory.
But I am getting the following error:
error C2664: 'FindFirstFileW ' : cannot convert parameter 1 from 'const char *' to 'LPCWSTR'
the code is as follows:
[code=c]
#include "stdafx.h"
#define _WIN32_WINNT 0x0400
#include <windows.h>
#include <stdio.h>
#include <string>
using namespace std;
int main(int argc, char *argv[])
{
WIN32_FIND_DATA FindFileData;
HANDLE hFind;
string str1 = "abc.txt";
printf ("Target file is %s.\n", str1.c_str());
hFind = FindFirstFile(s tr1.c_str(), &FindFileDat a);
if (hFind == INVALID_HANDLE_ VALUE)
{
printf ("Invalid File Handle. GetLastError reports %d\n", GetLastError()) ;
return (0);
}
else
{
printf ("The first file found is %s\n", FindFileData.cF ileName);
FindClose(hFind );
return (1);
}
}[/code]
any help is appreciated!
Thanks!!
I am presently working with folder and would like to find out the number of files in that particular directory.
But I am getting the following error:
error C2664: 'FindFirstFileW ' : cannot convert parameter 1 from 'const char *' to 'LPCWSTR'
the code is as follows:
[code=c]
#include "stdafx.h"
#define _WIN32_WINNT 0x0400
#include <windows.h>
#include <stdio.h>
#include <string>
using namespace std;
int main(int argc, char *argv[])
{
WIN32_FIND_DATA FindFileData;
HANDLE hFind;
string str1 = "abc.txt";
printf ("Target file is %s.\n", str1.c_str());
hFind = FindFirstFile(s tr1.c_str(), &FindFileDat a);
if (hFind == INVALID_HANDLE_ VALUE)
{
printf ("Invalid File Handle. GetLastError reports %d\n", GetLastError()) ;
return (0);
}
else
{
printf ("The first file found is %s\n", FindFileData.cF ileName);
FindClose(hFind );
return (1);
}
}[/code]
any help is appreciated!
Thanks!!
Comment