11 个解决方案
#1
FILE *Initfp;
if((Initfp=fopen("D:\\XCM_NUM.dat","r+b"))==NULL)
{
printf("D:\\XCM_NUM.dat can not open!!!!!!!!!!!!!!!!!!!!\n");
fclose(Initfp);
if((Initfp=fopen("D:\\XCM_NUM.dat","w+b"))==NULL){return(FALSE);};
fwrite(XCM_SETUP,sizeof(struct XCM_SETUP_st),1,Initfp);
}else
{
if((i=fread(XCM_SETUP,(sizeof(struct XCM_SETUP_st)),1,Initfp))==0)
{
printf("D:\\XCM_NUM.dat can not read!!!!!!!!!!!!!!!!!\n");
};
};
fclose(Initfp);
if((Initfp=fopen("D:\\XCM_NUM.dat","r+b"))==NULL)
{
printf("D:\\XCM_NUM.dat can not open!!!!!!!!!!!!!!!!!!!!\n");
fclose(Initfp);
if((Initfp=fopen("D:\\XCM_NUM.dat","w+b"))==NULL){return(FALSE);};
fwrite(XCM_SETUP,sizeof(struct XCM_SETUP_st),1,Initfp);
}else
{
if((i=fread(XCM_SETUP,(sizeof(struct XCM_SETUP_st)),1,Initfp))==0)
{
printf("D:\\XCM_NUM.dat can not read!!!!!!!!!!!!!!!!!\n");
};
};
fclose(Initfp);
#2
我习惯用这个:
long hFile = _open("c:\\abc.dat",_O_RDONLY|_O_BINARY);
long hFile = _open("c:\\abc.dat",_O_RDONLY|_O_BINARY);
#3
HFILE hFileS;
hFileS = _lopen("c:\\fsa800\\dat\\BHTT.DAT",OF_SHARE_DENY_NONE);
i = _llseek(hFileS,00,2);
_llseek(hFileS,0,0);
ii=_lread(hFileS,&SystemBuffer[0],i);
_lclose(hFileS);
hFileS = _lopen("c:\\fsa800\\dat\\BHTT.DAT",OF_SHARE_DENY_NONE);
i = _llseek(hFileS,00,2);
_llseek(hFileS,0,0);
ii=_lread(hFileS,&SystemBuffer[0],i);
_lclose(hFileS);
#4
CFile看看CSDN吧应该很容易搞定的
还有CStudioFile,是分行读取txt文本的
还有CStudioFile,是分行读取txt文本的
#5
CStdioFile aFile;
CFileException fx;
char DirectoryC[100];
CString Stringtemp;
GetModuleFileName(NULL,DirectoryC,100);
Stringtemp.Insert(0,DirectoryC);
Stringtemp.Delete(Stringtemp.Find("\\AGManager.exe",0),14);
Stringtemp=Stringtemp+"\\InfoRecord.txt";
if( !aFile.Open( Stringtemp, CFile::modeWrite | CFile::typeText, &fx ) )
{
TCHAR buf[ 255 ];
fx.GetErrorMessage( buf, 255 );
CString strPrompt( buf );
AfxMessageBox( strPrompt );
return;
}
aFile.SeekToEnd();
CTime CT=CTime::GetCurrentTime();
Description=Description+" "+CT.Format("%H:%M:%S,%A,%B %d,%Y")+"\n";
aFile.WriteString(Description);
aFile.Close();
CFileException fx;
char DirectoryC[100];
CString Stringtemp;
GetModuleFileName(NULL,DirectoryC,100);
Stringtemp.Insert(0,DirectoryC);
Stringtemp.Delete(Stringtemp.Find("\\AGManager.exe",0),14);
Stringtemp=Stringtemp+"\\InfoRecord.txt";
if( !aFile.Open( Stringtemp, CFile::modeWrite | CFile::typeText, &fx ) )
{
TCHAR buf[ 255 ];
fx.GetErrorMessage( buf, 255 );
CString strPrompt( buf );
AfxMessageBox( strPrompt );
return;
}
aFile.SeekToEnd();
CTime CT=CTime::GetCurrentTime();
Description=Description+" "+CT.Format("%H:%M:%S,%A,%B %d,%Y")+"\n";
aFile.WriteString(Description);
aFile.Close();
#6
我喜欢用CreateFile
#7
int handle;
handle = _open("F:\\1.txt",_O_RDWR);
if(handle != -1)
{
CFile file(handle);
char text[10];
file.Read(text,10);
}
我也不确定是否可以,你为什么一定要用CFile类呢?
handle = _open("F:\\1.txt",_O_RDWR);
if(handle != -1)
{
CFile file(handle);
char text[10];
file.Read(text,10);
}
我也不确定是否可以,你为什么一定要用CFile类呢?
#8
我都问了100遍了, snsins(初雪) 你是不是MM?
-----------
忘了说正事,严重同意楼上各位的解答^_^
-----------
忘了说正事,严重同意楼上各位的解答^_^
#9
(很严肃地)对楼上问题,严重D感兴趣。
#10
hehe~~~
demetry(智者橡木→→→★★★东北同仁会★★★) 你自己说呢
你说我是不是MM
demetry(智者橡木→→→★★★东北同仁会★★★) 你自己说呢
你说我是不是MM
#11
收藏
#1
FILE *Initfp;
if((Initfp=fopen("D:\\XCM_NUM.dat","r+b"))==NULL)
{
printf("D:\\XCM_NUM.dat can not open!!!!!!!!!!!!!!!!!!!!\n");
fclose(Initfp);
if((Initfp=fopen("D:\\XCM_NUM.dat","w+b"))==NULL){return(FALSE);};
fwrite(XCM_SETUP,sizeof(struct XCM_SETUP_st),1,Initfp);
}else
{
if((i=fread(XCM_SETUP,(sizeof(struct XCM_SETUP_st)),1,Initfp))==0)
{
printf("D:\\XCM_NUM.dat can not read!!!!!!!!!!!!!!!!!\n");
};
};
fclose(Initfp);
if((Initfp=fopen("D:\\XCM_NUM.dat","r+b"))==NULL)
{
printf("D:\\XCM_NUM.dat can not open!!!!!!!!!!!!!!!!!!!!\n");
fclose(Initfp);
if((Initfp=fopen("D:\\XCM_NUM.dat","w+b"))==NULL){return(FALSE);};
fwrite(XCM_SETUP,sizeof(struct XCM_SETUP_st),1,Initfp);
}else
{
if((i=fread(XCM_SETUP,(sizeof(struct XCM_SETUP_st)),1,Initfp))==0)
{
printf("D:\\XCM_NUM.dat can not read!!!!!!!!!!!!!!!!!\n");
};
};
fclose(Initfp);
#2
我习惯用这个:
long hFile = _open("c:\\abc.dat",_O_RDONLY|_O_BINARY);
long hFile = _open("c:\\abc.dat",_O_RDONLY|_O_BINARY);
#3
HFILE hFileS;
hFileS = _lopen("c:\\fsa800\\dat\\BHTT.DAT",OF_SHARE_DENY_NONE);
i = _llseek(hFileS,00,2);
_llseek(hFileS,0,0);
ii=_lread(hFileS,&SystemBuffer[0],i);
_lclose(hFileS);
hFileS = _lopen("c:\\fsa800\\dat\\BHTT.DAT",OF_SHARE_DENY_NONE);
i = _llseek(hFileS,00,2);
_llseek(hFileS,0,0);
ii=_lread(hFileS,&SystemBuffer[0],i);
_lclose(hFileS);
#4
CFile看看CSDN吧应该很容易搞定的
还有CStudioFile,是分行读取txt文本的
还有CStudioFile,是分行读取txt文本的
#5
CStdioFile aFile;
CFileException fx;
char DirectoryC[100];
CString Stringtemp;
GetModuleFileName(NULL,DirectoryC,100);
Stringtemp.Insert(0,DirectoryC);
Stringtemp.Delete(Stringtemp.Find("\\AGManager.exe",0),14);
Stringtemp=Stringtemp+"\\InfoRecord.txt";
if( !aFile.Open( Stringtemp, CFile::modeWrite | CFile::typeText, &fx ) )
{
TCHAR buf[ 255 ];
fx.GetErrorMessage( buf, 255 );
CString strPrompt( buf );
AfxMessageBox( strPrompt );
return;
}
aFile.SeekToEnd();
CTime CT=CTime::GetCurrentTime();
Description=Description+" "+CT.Format("%H:%M:%S,%A,%B %d,%Y")+"\n";
aFile.WriteString(Description);
aFile.Close();
CFileException fx;
char DirectoryC[100];
CString Stringtemp;
GetModuleFileName(NULL,DirectoryC,100);
Stringtemp.Insert(0,DirectoryC);
Stringtemp.Delete(Stringtemp.Find("\\AGManager.exe",0),14);
Stringtemp=Stringtemp+"\\InfoRecord.txt";
if( !aFile.Open( Stringtemp, CFile::modeWrite | CFile::typeText, &fx ) )
{
TCHAR buf[ 255 ];
fx.GetErrorMessage( buf, 255 );
CString strPrompt( buf );
AfxMessageBox( strPrompt );
return;
}
aFile.SeekToEnd();
CTime CT=CTime::GetCurrentTime();
Description=Description+" "+CT.Format("%H:%M:%S,%A,%B %d,%Y")+"\n";
aFile.WriteString(Description);
aFile.Close();
#6
我喜欢用CreateFile
#7
int handle;
handle = _open("F:\\1.txt",_O_RDWR);
if(handle != -1)
{
CFile file(handle);
char text[10];
file.Read(text,10);
}
我也不确定是否可以,你为什么一定要用CFile类呢?
handle = _open("F:\\1.txt",_O_RDWR);
if(handle != -1)
{
CFile file(handle);
char text[10];
file.Read(text,10);
}
我也不确定是否可以,你为什么一定要用CFile类呢?
#8
我都问了100遍了, snsins(初雪) 你是不是MM?
-----------
忘了说正事,严重同意楼上各位的解答^_^
-----------
忘了说正事,严重同意楼上各位的解答^_^
#9
(很严肃地)对楼上问题,严重D感兴趣。
#10
hehe~~~
demetry(智者橡木→→→★★★东北同仁会★★★) 你自己说呢
你说我是不是MM
demetry(智者橡木→→→★★★东北同仁会★★★) 你自己说呢
你说我是不是MM
#11
收藏