举一简单例子就行了
解决方案 »
- 程序中调用其他程序问题
- MFC dialog设置客户区大小
- 如何在一个文本文件中搜索是否存在一个IP,有的话就返回IP地址?
- 在自画按钮时,出现lnk2001错误?
- 如果要用MFC中的CSocket,但是在向导中没有选择的话怎么办啊?
- 关于十进制和十六进制的问题????????????????????????????????????????????????
- 如何用VC实现对网页和网络数据库的请求??
- 关于进程,请高手帮忙!!!!
- 我是新手,求好的软件测试的教程,站点,书籍.急,在线等候!!!!!!!!!!!!!!!
- 今天在书店看了<<unix高级编程>>(第二版)(1,2卷)不知该书怎样?望各位大虾指点!谢谢!
- 请教各位老大,如何响应CComboBox中编辑框输入完毕后的回车事件?
- 如何通过按按钮把控件隐藏
#include <stdio.h>WIN32_FIND_DATA FileData;
HANDLE hSearch;
DWORD dwAttrs;
char szDirPath[] = "c:\\TEXTRO\\";
char szNewPath[MAX_PATH];
char szHome[MAX_PATH];
BOOL fFinished = FALSE;
// Create a new directory.
if (!CreateDirectory(szDirPath, NULL))
{
printf("Couldn't create new directory.");
return;
}
// Start searching for .TXT files in the current directory.
hSearch = FindFirstFile("*.txt", &FileData);
if (hSearch == INVALID_HANDLE_VALUE)
{
printf("No .TXT files found.");
return;
}
// Copy each .TXT file to the new directory
// and change it to read only, if not already.
while (!fFinished)
{
lstrcpy(szNewPath, szDirPath);
lstrcat(szNewPath, FileData.cFileName);
if (CopyFile(FileData.cFileName, szNewPath, FALSE))
{
dwAttrs = GetFileAttributes(FileData.cFileName);
if (!(dwAttrs & FILE_ATTRIBUTE_READONLY))
{
SetFileAttributes(szNewPath,
dwAttrs | FILE_ATTRIBUTE_READONLY);
}
}
else
{
printf("Couldn't copy file.");
return;
}
if (!FindNextFile(hSearch, &FileData))
{
if (GetLastError() == ERROR_NO_MORE_FILES)
{
MessageBox(hwnd, "No more .TXT files.",
"Search completed.", MB_OK);
fFinished = TRUE;
}
else
{
printf("Couldn't find next file.");
return;
}
}
}
// Close the search handle.
FindClose(hSearch);