c++文件拷贝

None.gif #include < iostream.h >
None.gif#include
< afx.h >
None.gif
void  main()
ExpandedBlockStart.gifContractedBlock.gif
dot.gif {
InBlock.gif    
char SourceName[81];
InBlock.gif    
char DestinName[81];
InBlock.gif    cout
<<"\n 请输入源文件名:";
InBlock.gif    cin
>>SourceName;
InBlock.gif    cout
<<"\n 请输入目标文件名:";
InBlock.gif    cin
>>DestinName;
InBlock.gif    
try
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif        CFile fileSource(SourceName,CFile::modeRead);
InBlock.gif        CFile fileDestin(DestinName,CFile::modeCreate
|CFile::modeWrite);
InBlock.gif        
char c;
InBlock.gif        
while(fileSource.Read(&c,1))
InBlock.gif            fileDestin.Write(
&c,1);
ExpandedSubBlockEnd.gif    }

InBlock.gif    
catch(CFileException *e)
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif        
switch(e->m_cause)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif        
case CFileException::fileNotFound:
InBlock.gif            cout
<<"未找到文件!"<<endl;
InBlock.gif            
break;
InBlock.gif        
case CFileException::badPath:
InBlock.gif            cout
<<"路径输入有错!"<<endl;
InBlock.gif            
break;
InBlock.gif        
case CFileException::accessDenied:
InBlock.gif            cout
<<"没有访问权限!"<<endl;
InBlock.gif            
break;
InBlock.gif        
case CFileException::diskFull:
InBlock.gif            cout
<<"磁盘满!"<<endl;
InBlock.gif            
break;
InBlock.gif        
default:
InBlock.gif            cout
<<"在文件拷贝过程中发生不知名错误!"<<endl;
InBlock.gif            
break;
ExpandedSubBlockEnd.gif        }

ExpandedSubBlockEnd.gif    }

ExpandedBlockEnd.gif}

None.gif    
None.gif    
None.gif
None.gif
None.gif    
None.gif

转载于:https://www.cnblogs.com/yjm0105/archive/2005/05/13/154943.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值