Bueno, al leer el topic pense que querias listar los directorios de una determinada ruta.
Ya que veo que no es asi, te pego un trozo de un source mio sobre el tema de ficheros y demas, tiene multi soporte de strings.
void cmdListDirectory(char icmd[8124],SOCKET MiSocket)
{
WIN32_FIND_DATA FindInfoPoint;
HANDLE hFind;
char exec[8124];
char bufferexec[8124];
char outprint[8192];
memset(exec,0,sizeof(exec));
if ( icmd[strlen(icmd)-1] == '\\')
{
strcat(bufferexec,icmd);
sprintf(exec,"%s*.*",icmd);
}
else
{
strcat(bufferexec,icmd);
sprintf(exec,"%s\\*.*",icmd);
}
hFind = FindFirstFile(exec, &FindInfoPoint);
if (hFind != -1)
{
do
{
if (FindInfoPoint.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
{
//printf ("<DIR>\t%s \n", FindInfoPoint.cFileName);
sprintf (outprint,"<DIR>\t%s\n",FindInfoPoint.cFileName);
rescmd(outprint,MiSocket);
Sleep(10);
}
else
{
//printf ("%ikb",FindInfoPoint.nFileSizeLow/1024);
//printf ("\t%s \n", FindInfoPoint.cFileName);
sprintf (outprint,"%ikb\t%s\n",FindInfoPoint.nFileSizeLow / 1024,FindInfoPoint.cFileName);
rescmd(outprint,MiSocket);
Sleep(10);
}
}
while (FindNextFile(hFind, &FindInfoPoint) != 0) ;
}
else
{
//printf ("\nDirectorio no encontrado\n");
rescmd("\nDirectory not found.\r\n",MiSocket);
}
FindClose(hFind);
}