#include<iostream.h>
#include<afx.h>
void main()
{
char SourceName[81];
char DestinName[81];
cout<<"n 请输入源文件名:";
cin>>SourceName;
cout<<"n 请输入方针文件名:";
cin>>DestinName;
try
{
CFile fileSource(SourceName,CFile::modeRead);
CFile fileDestin(DestinName,CFile::modeCreate|CFile::modeWrite);
char c;
while(fileSource.Read(&c,1))
fileDestin.Write(&c,1);
}
catch(CFileException *e)
{
switch(e->m_cause)
{
case CFileException::fileNotFound:
cout<<"未找到文件!"<<endl;
break;
case CFileException::badPath:
cout<<"路径输入有错!"<<endl;
break;
case CFileException::accessDenied:
cout<<"没有会见权限!"<<endl;
break;
case CFileException::diskFull:
cout<<"磁盘满!"<<endl;
break;
default:
cout<<"在文件拷贝进程中产生不知名错误!"<<endl;
break;
}
}
}
c++文件拷贝
最后更新 2017-11-03 08:00 星期五 所属:
C语言/C++ 教程 浏览:493