大型文件读写问题C&C++

rain188si 2008-11-28 01:51:07
读取某一目录下的所有文件的名字及文件的最新修改时间,该目录下有文件夹有文档,文件夹中还包含文件夹和文档,要求就是把这里的所有文档的名字和时间都记录下来并写入TXT文件(一个文件名+时间占一行,我最后还要对文件进行比较),我用的CFileFind的函数,遇到N多问题,麻烦你帮我写一下,我已经无法前行了,用C或C++写,这是我的作业题,谢谢
...全文
242 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
SearchLife 2008-12-13
  • 打赏
  • 举报
回复
mark
rain188si 2008-12-01
  • 打赏
  • 举报
回复
谢谢您的帮助!我这编译不过呀,说是
Compiling...
dfdfdfsfdfsdfdfdsf.cpp
e:\test\dfdfdfsfdfsdfdfdsf\dfdfdfsfdfsdfdfdsf\dfdfdfsfdfsdfdfdsf.cpp(24) : warning C4996: 'fopen' was declared deprecated
d:\program files\microsoft visual studio 8\vc\include\stdio.h(234) : see declaration of 'fopen'
Message: 'This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_DEPRECATE. See online help for details.'
e:\test\dfdfdfsfdfsdfdfdsf\dfdfdfsfdfsdfdfdsf\dfdfdfsfdfsdfdfdsf.cpp(47) : error C2664: 'fprintf' : cannot convert parameter 2 from 'wchar_t *' to 'const char *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
e:\test\dfdfdfsfdfsdfdfdsf\dfdfdfsfdfsdfdfdsf\dfdfdfsfdfsdfdfdsf.cpp(102) : error C2664: 'Recurse' : cannot convert parameter 1 from 'const char [7]' to 'LPCTSTR
我按你的设置设了,还是这样能不能把你的整个工程压缩给我,3Q,邮件:2008_shiyu@163.com
至为感谢您对我的帮助
lc19890326 2008-11-28
  • 打赏
  • 举报
回复
厉害
killbug2004 2008-11-28
  • 打赏
  • 举报
回复
学习
spofmy 2008-11-28
  • 打赏
  • 举报
回复
suilj 2008-11-28
  • 打赏
  • 举报
回复
高人!!
就呆在云上 2008-11-28
  • 打赏
  • 举报
回复
ok,写好了,程序如下,控制台程序,vs2005可以用,但是要进行项目设置:

菜单栏--》项目--》--》“工程”属性页--》配置属性--》常规--》右边有两个框,其中项目默认值:
MFC的使用:选择:在共享dll中使用MFC
字符集:使用多字节字符集

我把读出的文件夹的内容写入了一个叫做readme.txt文件,如下:
-------- 文件
使用QT 4的C++ GUI编程.zip
Created : 03/08/08 13:53:41
Last Access: 09/09/08 00:00:00
Last Write : 03/08/08 13:54:02
-------- 文件
qt-x11-opensource-src-4.3.4.tar.gz
Created : 03/09/08 21:27:52
Last Access: 09/09/08 00:00:00
Last Write : 03/09/08 21:31:54
-------- 文件
Qt.4.C++.GUI..pdf
Created : 03/10/08 21:57:39
Last Access: 09/09/08 00:00:00
Last Write : 03/10/08 21:49:48
-------- 文件
qtopia-core-opensource-src-4.3.3.tar.gz
Created : 03/11/08 21:57:10
Last Access: 09/09/08 00:00:00
Last Write : 03/11/08 21:59:38
-------- 文件
qt-win-patch.zip
Created : 03/14/08 08:37:52
Last Access: 09/09/08 00:00:00
Last Write : 03/14/08 08:38:00
-------- 文件
License.txt
Created : 03/14/08 10:48:38
Last Access: 09/09/08 00:00:00
Last Write : 03/14/08 10:51:04
-------- 文件
msvc-include-path-settings.png
Created : 03/13/08 17:04:29
Last Access: 11/28/08 00:00:00
Last Write : 03/13/08 17:04:34
-------- 文件
msvc-lib-path-settings.png
Created : 03/13/08 17:16:13
Last Access: 11/28/08 00:00:00
Last Write : 03/13/08 17:16:14
-------- 文件
qt-tools-built-using-vc2005.jpg
Created : 03/13/08 17:16:21
Last Access: 11/28/08 00:00:00
Last Write : 03/13/08 17:17:36
-------- 文件
qt4.chm
Created : 03/10/08 21:57:38
Last Access: 09/09/08 00:00:00
Last Write : 03/10/08 21:22:46
-------- 文件夹
d:\qt4\qt商业版
-------- 文件
qt-vsintegration-1.3.1.exe
Created : 03/14/08 10:37:31
Last Access: 11/28/08 00:00:00
Last Write : 03/14/08 10:46:44
-------- 文件
qt-win-commercial-src-4.3.1.zip
Created : 03/14/08 10:37:17
Last Access: 09/09/08 00:00:00
Last Write : 03/14/08 10:48:02
-------- 文件
Thumbs.db
Created : 06/23/08 16:16:34
Last Access: 09/09/08 00:00:00
Last Write : 06/23/08 16:16:36
-------- 文件
qtcreator-0.9-windows-setup.zip
Created : 11/11/08 13:12:01
Last Access: 11/11/08 00:00:00
Last Write : 11/11/08 13:31:36


代码:
#include <iostream> 
#include <afx.h>
#include <Windows.h>
using namespace std;

CFileFind a;
FILETIME myaccesstime, mywritetime;
FILE *fp = fopen("readme.txt", "w+");
void Recurse(LPCTSTR pstr)
{
CFileFind finder;
CString strWildcard(pstr);
strWildcard += _T("\\*.*");
BOOL bWorking = finder.FindFile(strWildcard);
while (bWorking)
{
bWorking = finder.FindNextFile();
if (finder.IsDots())
continue;

if (finder.IsDirectory())
{
fprintf(fp, "-------- 文件夹\n" );
CString str = finder.GetFilePath();
fprintf(fp,_T("%s\n"), (LPCTSTR)str);
Recurse(str);
}
else
{
fprintf(fp, "-------- 文件\n" );
fprintf(fp, finder.GetFileName().GetBuffer(), "\n" );
CTime tempTime;
CString str;
fprintf(fp,_T("\n\tCreated : "));
if (finder.GetCreationTime(tempTime))
{
str = tempTime.Format(_T("%c"));
fprintf(fp,_T("%s\n"), (LPCTSTR) str);
}
else
{
fprintf(fp,_T("(unavailable)\n"));
}

fprintf(fp,_T("\tLast Access: "));
if (finder.GetLastAccessTime(tempTime))
{
str = tempTime.Format(_T("%c"));
fprintf(fp,_T("%s\n"), (LPCTSTR) str);
}
else
{
fprintf(fp,_T("(unavailable)\n"));
}

fprintf(fp,_T("\tLast Write : "));
if (finder.GetLastWriteTime(tempTime))
{
str = tempTime.Format(_T("%c"));
fprintf(fp,_T("%s\n"), (LPCTSTR) str);
}
}
}
finder.Close();
}

int main()
{
Recurse("d:\\qt4");
fclose(fp);
}
Non_Recursive 2008-11-28
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 ztz0223 的回复:]
==
一会写给你
[/Quote]up
Longinc 2008-11-28
  • 打赏
  • 举报
回复
UP一个
就呆在云上 2008-11-28
  • 打赏
  • 举报
回复
==
一会写给你
rain188si 2008-11-28
  • 打赏
  • 举报
回复
问题补充一下:开发环境VisualStudio2005 或2003
wudeshou82666 2008-11-28
  • 打赏
  • 举报
回复
搬凳子,等高手来
内容概要:本文提出了一种融合模型预测控制(MPC)与人工势场法(APF)的船舶运动规划方法,旨在解决复杂海上交通场景下符合国际海上避碰规则(COLREG)的智能避碰路径规划问题。该方法充分利用MPC的滚动优化与前瞻预测能力,结合APF对动态障碍物的实时响应优势,构建包含目标引力场与多船斥力场的综合势场模型,并显式嵌入COLREG规则以确保避让行为的合法性与可解释性。通过在多船会遇、交叉、追越等多种复杂场景下的Matlab仿真实验,验证了该方法在生成安全、平滑、合规轨迹方面的有效性与鲁棒性,为智能船舶自主航行提供了可靠的决策支持。; 适合人群:从事航海自动化、智能船舶系统、海洋机器人、路径规划与智能控制研究的科研人员,以及具备Matlab编程与控制系统基础的研究生和工程技术人员。; 使用场景及目标:① 实现多船复杂交互环境下的智能避碰决策;② 开发符合国际法规的无人船自主航行系统;③ 深入学习MPC与APF融合算法的设计原理与仿真实现;④ 为智能航运、海上交通管理系统提供核心算法技术支持。; 阅读建议:建议结合提供的Matlab代码进行仿真实验,重点理解势场函数构建、COLREG规则的形式化表达、约束处理机制及MPC滚动优化的实现细节,同时对照国际避碰规则条款验证算法行为的合规性与合理性。

65,211

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧