VS2010编译C++错误:warning C4244和error C2039,求教怎么办?
出错的那段代码:voidCFileCopyDlg::OnBnClickedCopy(){if(pathname.IsEmpty())return;if(fullname....
出错的那段代码:
void CFileCopyDlg::OnBnClickedCopy()
{
if(pathname.IsEmpty())
return;
if(fullname.IsEmpty())
return;
readfile=new CFile(pathname,CFile::modeRead);
HANDLE hfile=::CreateFile(fullname,GENERIC_WRITE|GENERIC_WRITE,0,0,CREATE_NEW,FILE_ATTRIBUTE_NORMAL,0);
CloseHandle(hfile);
writefile=new CFile(fullname,CFile::modeWrite);
filelen=readfile->GetLength(); 213行
ldiv_t r;
r=ldiv(filelen,100);
long pos=r.quot;
long ipos;
ipos=pos;
int i=0;
hGlobal = GlobalAlloc(GMEM_MOVEABLE,512);
pvData = GlobalLock(hGlobal);
while(1){
ZeroMemory(pvData,512);
readlen=readfile->ReadHuge(pvData,512); 224行出错
poslen=readfile->GetPosition(); 225行出错
if(poslen>ipos)
{
ipos+=pos;
i++;
}
m_fileproc.SetPos(i);
m_fileproc.Invalidate();
writefile->WriteHuge(pvData,readlen); 233行出错
if(poslen==filelen)
break;
}
AfxMessageBox("复制完成");
m_fileproc.SetPos(0);
GlobalUnlock(hGlobal);
readfile->Close();
writefile->Close();
}
提示错误:
d:\新建文件夹\vs项目\filecopy\filecopy\filecopydlg.cpp(213): warning C4244: “=”: 从“ULONGLONG”转换到“long”,可能丢失数据
d:\新建文件夹\vs项目\filecopy\filecopy\filecopydlg.cpp(224): error C2039: “ReadHuge”: 不是“CFile”的成员
d:\vs2010\vc\atlmfc\include\afx.h(989) : 参见“CFile”的声明
d:\新建文件夹\vs项目\filecopy\filecopy\filecopydlg.cpp(225): warning C4244: “=”: 从“ULONGLONG”转换到“long”,可能丢失数据
d:\新建文件夹\vs项目\filecopy\filecopy\filecopydlg.cpp(233): error C2039: “WriteHuge”: 不是“CFile”的成员
d:\vs2010\vc\atlmfc\include\afx.h(989) : 参见“CFile”的声明 展开
void CFileCopyDlg::OnBnClickedCopy()
{
if(pathname.IsEmpty())
return;
if(fullname.IsEmpty())
return;
readfile=new CFile(pathname,CFile::modeRead);
HANDLE hfile=::CreateFile(fullname,GENERIC_WRITE|GENERIC_WRITE,0,0,CREATE_NEW,FILE_ATTRIBUTE_NORMAL,0);
CloseHandle(hfile);
writefile=new CFile(fullname,CFile::modeWrite);
filelen=readfile->GetLength(); 213行
ldiv_t r;
r=ldiv(filelen,100);
long pos=r.quot;
long ipos;
ipos=pos;
int i=0;
hGlobal = GlobalAlloc(GMEM_MOVEABLE,512);
pvData = GlobalLock(hGlobal);
while(1){
ZeroMemory(pvData,512);
readlen=readfile->ReadHuge(pvData,512); 224行出错
poslen=readfile->GetPosition(); 225行出错
if(poslen>ipos)
{
ipos+=pos;
i++;
}
m_fileproc.SetPos(i);
m_fileproc.Invalidate();
writefile->WriteHuge(pvData,readlen); 233行出错
if(poslen==filelen)
break;
}
AfxMessageBox("复制完成");
m_fileproc.SetPos(0);
GlobalUnlock(hGlobal);
readfile->Close();
writefile->Close();
}
提示错误:
d:\新建文件夹\vs项目\filecopy\filecopy\filecopydlg.cpp(213): warning C4244: “=”: 从“ULONGLONG”转换到“long”,可能丢失数据
d:\新建文件夹\vs项目\filecopy\filecopy\filecopydlg.cpp(224): error C2039: “ReadHuge”: 不是“CFile”的成员
d:\vs2010\vc\atlmfc\include\afx.h(989) : 参见“CFile”的声明
d:\新建文件夹\vs项目\filecopy\filecopy\filecopydlg.cpp(225): warning C4244: “=”: 从“ULONGLONG”转换到“long”,可能丢失数据
d:\新建文件夹\vs项目\filecopy\filecopy\filecopydlg.cpp(233): error C2039: “WriteHuge”: 不是“CFile”的成员
d:\vs2010\vc\atlmfc\include\afx.h(989) : 参见“CFile”的声明 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询