以下代码是对文件操作,往文件中写入内容,可以成功,但是文件可以用
写字板看到内容,我希望内容是二进制的,用写字板等工具不能看其内容,
该怎么办?CFile MyFile;
CString FileName,str,Content;
FileName.Format("%s","MyFile.cgp");//文件名
Content = "this is dog";//内容if (MyFile.Open(FileName,CFile::modeReadWrite|CFile::typeBinary))//如果已存在
{
MyFile.SeekToEnd();
}
else
{
if (MyFile.Open(FileName,CFile::modeCreate|CFile::modeReadWrite|CFile::typeBinary))//如果不存在就创建
{
MyFile.SeekToEnd();
}
}
str.Format("%s",Content);//把内容给str
int len = str.GetLength();
char* lpstrContentData = str.GetBuffer(len);//再给char*
if (lpstrContentData == NULL)
{
;
}
else
{
MyFile.Write(lpstrContentData,len);//把内容写入文件
MyFile.Flush();
}
写字板看到内容,我希望内容是二进制的,用写字板等工具不能看其内容,
该怎么办?CFile MyFile;
CString FileName,str,Content;
FileName.Format("%s","MyFile.cgp");//文件名
Content = "this is dog";//内容if (MyFile.Open(FileName,CFile::modeReadWrite|CFile::typeBinary))//如果已存在
{
MyFile.SeekToEnd();
}
else
{
if (MyFile.Open(FileName,CFile::modeCreate|CFile::modeReadWrite|CFile::typeBinary))//如果不存在就创建
{
MyFile.SeekToEnd();
}
}
str.Format("%s",Content);//把内容给str
int len = str.GetLength();
char* lpstrContentData = str.GetBuffer(len);//再给char*
if (lpstrContentData == NULL)
{
;
}
else
{
MyFile.Write(lpstrContentData,len);//把内容写入文件
MyFile.Flush();
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货