CFILE 文件拷贝问题

 1 BOOL AddtoFile(LPCTSTR pPathDest,LPCTSTR pPathSrc,CString& str)
 2 {
 3     BOOL bTrue = FALSE;
 4     CFile pFile1;
 5     if (pFile1.Open(pPathSrc,CFile::modeReadWrite))
 6     {
 7          pFile1.SeekToEnd();
 8          int iLength = str.GetLength();
 9          pFile1.Write(str.GetBuffer(iLength),iLength);
10         iLength = pFile1.GetLength();
11         char * pp = new char[length];
12         memset(pp,0,length);
13         pFile1.SeekToBegin();
14         pFile1.ReadHuge(pp,length);
15         CFile pFile2;
16         if (pFile2.Open(pPathDest,CFile::modeCreate|CFile::modeReadWrite))
17         {
18             pFile2.SeekToBegin();
19             pFile2.WriteHuge(pp,length);
20             bTrue = TRUE;
21         }
22         pFile2.Close();
23         delete []pp;
24     }
25     pFile1.Close();
26 
27     return bTrue;;
28 }

这段代码是文件pPathSrc内容增加一个字符串并拷贝到文件pPathDest中

是否可以将代码改的跟简洁一些呢?


posted on 2008-04-03 16:26 鱼香 阅读(794) 评论(1)  编辑 收藏 引用

评论

# re: CFILE 文件拷贝问题 2008-04-03 17:28 鱼肉大包子

随机数简单语句
srand((unsigned int)time(NULL));
int x = rand()%999999999;  回复  更多评论   


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理


<2024年4月>
31123456
78910111213
14151617181920
21222324252627
2829301234
567891011

导航

统计

常用链接

留言簿(1)

随笔档案

搜索

最新评论

阅读排行榜

评论排行榜