EDN Admin
Well-known member
Im using code based from this webpage: http://msdn.microsoft.com/en-us/library/aa365200(v=VS.85).aspx
but when i try to list the files and folders in cocuments and Settings folder nothing comes up.
There are other "special" folders that dont work either, like "My Documents".
any ideas?
WIN32_FIND_DATA ffd;<br/>
LARGE_INTEGER filesize;<br/>
TCHAR szDir[MAX_PATH];<br/>
size_t length_of_arg;<br/>
HANDLE hFind = INVALID_HANDLE_VALUE;<br/>
DWORD dwError=0;<br/>
<br/>
// If the directory is not specified as a command-line argument,<br/>
// print usage.<br/>
<br/>
// Check that the input path plus 3 is not longer than MAX_PATH.<br/>
// Three characters are for the "*" plus NULL appended below.<br/>
<br/>
if (m_sPath.length() > (MAX_PATH - 3))<br/>
{<br/>
return;<br/>
}<br/>
<br/>
// Prepare string for use with FindFile functions. First, copy the<br/>
// string to a buffer, then append * to the directory name.<br/>
<br/>
StringCchCopy(szDir, MAX_PATH, m_sPath.c_str());<br/>
StringCchCat(szDir, MAX_PATH, TEXT("\*"));<br/>
<br/>
// Find the first file in the directory.<br/>
<br/>
hFind = FindFirstFile(szDir, &ffd);<br/>
<br/>
if (INVALID_HANDLE_VALUE == hFind) <br/>
{<br/>
return;<br/>
} <br/>
<br/>
for(int y = 0; y < TOTAL_CLIPS; y++)<br/>
m_pFileBrowserFolderEntry[y].m_bSet = false;<br/>
<br/>
// List all the files in the directory with some info about them.<br/>
int m_iEntryIndex = 0;<br/>
do<br/>
{<br/>
if (ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)<br/>
{<br/>
if (m_iEntryIndex < TOTAL_CLIPS)<br/>
m_pFileBrowserFolderEntry[m_iEntryIndex].SetText(ffd.cFileName);<br/>
<br/>
m_iEntryIndex++;<br/>
}<br/>
else<br/>
{<br/>
filesize.LowPart = ffd.nFileSizeLow;<br/>
filesize.HighPart = ffd.nFileSizeHigh;<br/>
_tprintf(TEXT(" %s %ld bytesn"), ffd.cFileName, filesize.QuadPart);<br/>
}<br/>
<br/>
}<br/>
while (FindNextFile(hFind, &ffd) != 0);
View the full article
but when i try to list the files and folders in cocuments and Settings folder nothing comes up.
There are other "special" folders that dont work either, like "My Documents".
any ideas?
WIN32_FIND_DATA ffd;<br/>
LARGE_INTEGER filesize;<br/>
TCHAR szDir[MAX_PATH];<br/>
size_t length_of_arg;<br/>
HANDLE hFind = INVALID_HANDLE_VALUE;<br/>
DWORD dwError=0;<br/>
<br/>
// If the directory is not specified as a command-line argument,<br/>
// print usage.<br/>
<br/>
// Check that the input path plus 3 is not longer than MAX_PATH.<br/>
// Three characters are for the "*" plus NULL appended below.<br/>
<br/>
if (m_sPath.length() > (MAX_PATH - 3))<br/>
{<br/>
return;<br/>
}<br/>
<br/>
// Prepare string for use with FindFile functions. First, copy the<br/>
// string to a buffer, then append * to the directory name.<br/>
<br/>
StringCchCopy(szDir, MAX_PATH, m_sPath.c_str());<br/>
StringCchCat(szDir, MAX_PATH, TEXT("\*"));<br/>
<br/>
// Find the first file in the directory.<br/>
<br/>
hFind = FindFirstFile(szDir, &ffd);<br/>
<br/>
if (INVALID_HANDLE_VALUE == hFind) <br/>
{<br/>
return;<br/>
} <br/>
<br/>
for(int y = 0; y < TOTAL_CLIPS; y++)<br/>
m_pFileBrowserFolderEntry[y].m_bSet = false;<br/>
<br/>
// List all the files in the directory with some info about them.<br/>
int m_iEntryIndex = 0;<br/>
do<br/>
{<br/>
if (ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)<br/>
{<br/>
if (m_iEntryIndex < TOTAL_CLIPS)<br/>
m_pFileBrowserFolderEntry[m_iEntryIndex].SetText(ffd.cFileName);<br/>
<br/>
m_iEntryIndex++;<br/>
}<br/>
else<br/>
{<br/>
filesize.LowPart = ffd.nFileSizeLow;<br/>
filesize.HighPart = ffd.nFileSizeHigh;<br/>
_tprintf(TEXT(" %s %ld bytesn"), ffd.cFileName, filesize.QuadPart);<br/>
}<br/>
<br/>
}<br/>
while (FindNextFile(hFind, &ffd) != 0);
View the full article