怎么得到某个磁盘下所有的文件夹
解决方案 »
- 操作word表格 自定义样式 问题
- 程序调试的时候出现Unhandled exception 0xC0000005;Access Violation怎么回事
- 谁知道怎样用udp或者tcp实现群聊????
- 请问如何诊断串口接受缓冲是否受到数据呢??
- 高分求教,不够再加。解决全部给分
- 请问如何给程序减肥?
- 小试SDK对话框显示菜单,但还是不显示出来,help!
- ■■■■■■【谁能用AutoCad r14 的COM接口画个圆,我给他100分】■■■■■■■■
- 一个文件中的日期类型转换关系,求救!
- VS2008 MFC 请问如何连接数据库,我通过菜单栏-》工具栏-》连接数据库可以么?
- 简单问题困惑着我啊。。请高手帮助啊。
- vc6.0中有使用托管扩展这项功能吗?如果有的话在哪找到
#define _WIN32_WINNT 0x0501
#include <Windows.h>
#include <stdio.h>
#include <malloc.h>
#include <tchar.h>
#include <wchar.h>
#include <strsafe.h>#define BUFSIZE MAX_PATHint _tmain(int argc, TCHAR *argv[])
{
WIN32_FIND_DATA FindFileData;
HANDLE hFind = INVALID_HANDLE_VALUE;
DWORD dwError;
LPTSTR DirSpec;
size_t length_of_arg;
INT retval; DirSpec = (LPTSTR) malloc (BUFSIZE); if( DirSpec == NULL )
{
printf( "Insufficient memory available\n" );
retval = 1;
goto Cleanup;
}
// Check for the directory to query, specified as
// a command-line parameter; otherwise, print usage.
if(argc != 2)
{
_tprintf(TEXT("Usage: Test <dir>\n"));
retval = 2;
goto Cleanup;
} // Check that the input is not larger than allowed.
StringCbLength(argv[1], BUFSIZE, &length_of_arg); if (length_of_arg > (BUFSIZE - 2))
{
_tprintf(TEXT("Input directory is too large.\n"));
retval = 3;
goto Cleanup;
} _tprintf (TEXT("Target directory is %s.\n"), argv[1]); // Prepare string for use with FindFile functions. First,
// copy the string to a buffer, then append '\*' to the
// directory name.
StringCbCopyN (DirSpec, BUFSIZE, argv[1], length_of_arg+1);
StringCbCatN (DirSpec, BUFSIZE, TEXT("\\*"), 2*sizeof(TCHAR)); // Find the first file in the directory.
hFind = FindFirstFile(DirSpec, &FindFileData); if (hFind == INVALID_HANDLE_VALUE)
{
_tprintf (TEXT("Invalid file handle. Error is %u.\n"),
GetLastError());
retval = (-1);
}
else
{
_tprintf (TEXT("First file name is: %s\n"),
FindFileData.cFileName);
// List all the other files in the directory.
while (FindNextFile(hFind, &FindFileData) != 0)
{
//在这里检查FindFileData属性,是文件夹则输出 _tprintf (TEXT("Next file name is: %s\n"),
FindFileData.cFileName);
}
dwError = GetLastError();
FindClose(hFind);
if (dwError != ERROR_NO_MORE_FILES)
{
_tprintf (TEXT("FindNextFile error. Error is %u.\n"),
dwError);
retval = (-1);
goto Cleanup;
}
}
retval = 0;Cleanup:
free(DirSpec);
return retval;}