#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;
}
}
#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;
}
}