void CloseFilePointer(CStdioFile& file)
{
if (file.m_pStream != NULL)
{
file.Close();
}
}
int ConvertFileFormat(CStdioFile& file,CString strTemBuf,CString strTemFile,const CString strFlag)
{
if (file.m_pStream!=NULL)
{
file.Close();
}
if (strTemBuf == strFlag)
{
//to do convert file format
strTemFile = "/"" + strTemFile;
strTemFile = strTemFile + "/"";
if ((long)ShellExecute(NULL, "open", "TxtConvertDtoU.exe", strTemFile, NULL, SW_SHOW)<33)
{
cout<<endl<<"Error:/n"<<strTemFile<<" file format convert failed,maybe /n the TxtConvertDtoU.exe is not find "<<endl;
return 1;
}
}
return 0;
}
本文介绍了使用C++进行文件关闭操作及文件格式转换的方法。通过CStdioFile类实现文件指针的安全关闭,并利用ShellExecute函数完成特定条件下的文件格式转换任务。
343

被折叠的 条评论
为什么被折叠?



