标签:read reset cal 搜索 app scale win32 分类 har
(1)读文件VOID CScale3DCControl::ReadLauFile(CString strFileName,CRichEditCtrl & richEdit)
{
CString strFilePath = GetApplicationPath() + strFileName;
CFile file(strFilePath, CFile::modeRead);
char * pBuf;
DWORD dwFileLen; //定义存储文件长度的变量
dwFileLen = file.GetLength();
pBuf = new char[dwFileLen + 1];
pBuf[dwFileLen] = 0; //把最后一位一0结尾 表示文件结束
file.Read(pBuf, dwFileLen);
USES_CONVERSION;
richEdit.SetWindowText(A2W(pBuf));
GetKeyWordFromText(A2W(pBuf));
file.Close();
}(2)写文件
VOID CScale3DCControl::SaveLuaFile(CRichEditCtrl & richEdit, CString strFileName)
{
CString strPath = GetApplicationPath() + _T("lua\\") + strFileName;
CFile file(strPath,CFile::modeCreate | CFile::modeWrite);
CString strTemp;
richEdit.GetWindowText(strTemp);
USES_CONVERSION;
file.Write(W2A(strTemp), strlen(W2A(strTemp)));
file.Close();
}(3)搜索文件夹下的所有文件名
void CScale3DCControl::GetFileFromDirectory(CString csDirPath, CListBox & list)
//csDirPath为文件夹名字,把该文件夹底下的jpg文
//件的名字存储到容器 m_FileList中,如果不分类型
//则把csDirPath+="\\*.jpg";改为csDirPat+="\*."
{
m_FileList.clear();
list.ResetContent();
csDirPath = GetApplicationPath()+csDirPath+ _T("\\*.lua");
HANDLE file;
WIN32_FIND_DATA fileData;
file = FindFirstFile(csDirPath.GetBuffer(), &fileData);
if (file != INVALID_HANDLE_VALUE)
{
m_FileList.push_back(fileData.cFileName);
list.AddString(fileData.cFileName);
bool bState = false;
bState = FindNextFile(file, &fileData);
while (bState) {
m_FileList.push_back(fileData.cFileName);
list.AddString(fileData.cFileName);
bState = FindNextFile(file, &fileData);
}
}
else
{
;// AfxMessageBox("文件夹中没有shp文件!");
}
}
CString CScale3DCControl::GetApplicationPath()
{
WCHAR buff[255] = { 0 };
::GetModuleFileName(0, buff, 255);
CString strAppFullName;
strAppFullName.Format(_T("%s"), buff);
CString strAppPath = _T("");
strAppPath = strAppFullName.Left(strAppFullName.ReverseFind('\\') + 1);
return strAppPath;
}标签:read reset cal 搜索 app scale win32 分类 har
原文地址:http://blog.51cto.com/9233403/2130081