📄 subject_19840.htm
字号:
<p>
序号:19840 发表者:odq 发表日期:2002-10-31 19:15:49
<br>主题:毛病多多的程序, 有谁帮我调试通过。我万分感谢,
<br>内容:#include "stdio.h"<BR>#include "iostream.h"<BR>void main()<BR>{<BR> CString strFile1="c:\\fdemo1.txt";<BR> CFile file((LPSTSTR)strFile1,CFile::modeNoTruncate|CFile::modeCreate|CFile::modeWrite);<BR> CString strNL;<BR> strNL.Format("\r\n");<BR> CString strBuf="This is Demo of CFile."+strNl+"We'll see some information of this file"+strNL;<BR> file.SeekToBegin();<BR> file.Write((void *)(LPCTSTR)strBuf,strBuf.GetLength());<BR> char pbuf[500];<BR> CFileStatus filestatus;<BR> CString createtime;<BR> CString recentWtime;<BR> CString recentAtime;<BR> file.GetStatus(filestatus);<BR> createtime=filestatus.m_ctime.Format("Createtime:%Y-%b-%D%H:%M:%S\n");<BR> recentWtime=filestatus.m_mtime.Format("recedntWrite:%Y-%b-%D%H:%M:%S\n");<BR> recentAtime=filestatus.m_atime.Format("recentAtime:%Y-%b-%D%H:%M:%S\n");<BR> file.SeekToBegin();<BR> UINT bBytesRead=file.Read(pbuf,500);<BR> cout<<pbuf<<"\n\n\n";<BR> cout<<createtime;<BR> cout<<recentWrite;<BR> cout<<recentAtime;<BR> cout<<"FileSize:"<<filestatus.m_size<<"\n";<BR> cout<<"Attribute:"<<(int)filestatus.m_attribute<<"\n";<BR> cout<<"FileName: "<<filestatus.m_szFullName<<"\n";<BR> file.Close();<BR> CString strFile2="c:\FDEMO2.TXT";<BR> ::CopyFile((LPCTSTR)strFile1,(LPCTSTR)strFile2,FALSE);<BR> ::MoveFileEx("c:\\FDEMO1.TXT","D:\\FDEMO1.TXT",MOVEFILE_REPLACE_EXISTING|MOVEFILE_COPY_ALLOWED);<BR> ::MoveFile("c:\\FDEMO2.TXT","C:\\FDEMO2A.TXT");<BR> ::CopyFile("d:\\FDEMO1.TXT","D:\\FDEMO2.TXT",FALSE);<BR> ::DeleteFile ("d:\\FDEMO1.TXT");<BR>}<BR>
<br><a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p>
<hr size=1>
<blockquote><p>
回复者:不说 回复日期:2002-10-31 20:55:31
<br>内容:给你整理了一哈,记得要放到一个支持MFC的Console程序里哟<BR><BR> CString strFile1="c:\\fdemo1.txt";<BR> CFile file(strFile1,CFile::modeNoTruncate|CFile::modeCreate|CFile::modeWrite);<BR> CString strNL;<BR> strNL.Format("\r\n");<BR> CString strBuf="This is Demo of CFile."+strNL+"We'll see some information of this file"+strNL;<BR> file.SeekToBegin();<BR> file.Write((void *)(LPCTSTR)strBuf,strBuf.GetLength());<BR> file.Close();<BR> <BR> CFile file1(strFile1, CFile::modeRead);<BR> char pbuf[500];<BR> memset(pbuf,0,500);<BR> CFileStatus filestatus;<BR> CString createtime;<BR> CString recentWtime;<BR> CString recentAtime;<BR> file1.GetStatus(filestatus);<BR> createtime=filestatus.m_ctime.Format("Createtime:%Y-%b-%D%H:%M:%S\n");<BR> recentWtime=filestatus.m_mtime.Format("recedntWrite:%Y-%b-%D%H:%M:%S\n");<BR> recentAtime=filestatus.m_atime.Format("recentAtime:%Y-%b-%D%H:%M:%S\n");<BR> file1.SeekToBegin();<BR> UINT bBytesRead=file1.Read(pbuf,500);<BR> cout<<pbuf<<"\n\n\n";<BR> cout<<createtime;<BR> cout<<recentWtime;<BR> cout<<recentAtime;<BR> cout<<"FileSize:"<<filestatus.m_size<<"\n";<BR> cout<<"Attribute:"<<(int)filestatus.m_attribute<<"\n";<BR> cout<<"FileName: "<<filestatus.m_szFullName<<"\n";<BR> file1.Close();<BR> CString strFile2="c:\\FDEMO2.TXT";<BR> ::CopyFile((LPCTSTR)strFile1,(LPCTSTR)strFile2,FALSE);<BR> ::MoveFileEx("c:\\FDEMO1.TXT","D:\\FDEMO1.TXT",MOVEFILE_REPLACE_EXISTING|MOVEFILE_COPY_ALLOWED);<BR> ::MoveFile("c:\\FDEMO2.TXT","C:\\FDEMO2A.TXT");<BR> ::CopyFile("d:\\FDEMO1.TXT","D:\\FDEMO2.TXT",FALSE);<BR> ::DeleteFile ("d:\\FDEMO1.TXT");
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:odq 回复日期:2002-11-01 14:29:54
<br>内容:请问老兄,你真的把我程序调试通过了, 我怎么编译的时候还是老样子啥。 呐闷<BR> 请不问老兄高抬高手, 能不能把你的完整程序帖出来,包括头文件等。<BR> 注: 我刚开始是用stdafx.h这个头文件, 而不是stdio.h这个头文件。<BR> 程序编译时说找不到stdafx.h这个头文件。
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:不说 回复日期:2002-11-01 14:32:20
<br>内容:我不是说了嘛?你重新建立一个console工程,在第二步的时候记得选最后一个“support MFC”才可以的,你现在的程序不支持MFC,你用的C开头的那些东西统统的没有,明白?
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:odq 回复日期:2002-11-01 14:37:09
<br>内容:不是很明白, 那么那段代码应该放在哪个文件的哪个位置呢? 我在这说谢谢了。
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:不说 回复日期:2002-11-01 14:39:57
<br>内容:啊??你新建一个支持MFC的console工程,然后会有两个.cpp文件,一个是stdafx.cpp,不要管它,另外一个是你工程名字.cpp,把上边的代码加到这个文件的int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])<BR>{<BR>}<BR>里就成了
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
<font color=red>答案被接受</font><br>回复者:不说 回复日期:2002-11-01 14:41:20
<br>内容:注意这个_tmain里的第一行<BR>int nRetCode = 0;<BR>和最后一行<BR>return nRetCode;<BR>要保留,否则你编译还是过不去
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:odq 回复日期:2002-11-03 21:34:19
<br>内容:不说,真的谢谢你, 我应该怎样报答你呢, <BR><BR> 希望以后你能多多指教。~~~~~~~~
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -