64,652
社区成员
发帖
与我相关
我的任务
分享
TCHAR pszPath[MAX_PATH];
BROWSEINFO bi;
bi.hwndOwner = this->GetSafeHwnd();
bi.pidlRoot = NULL;
bi.pszDisplayName = NULL;
bi.lpszTitle = TEXT("请选择文件夹");
bi.ulFlags = BIF_RETURNFSANCESTORS | BIF_RETURNONLYFSDIRS;
bi.lpfn = NULL;
bi.lParam = 0;
bi.iImage = 0;
LPITEMIDLIST pidl = SHBrowseForFolder(&bi);
if (pidl == NULL)
{
return;
}
if (SHGetPathFromIDListW(pidl, pszPath))
{
CString strPath = pszPath;
if(strPath.Right(1) != _T("\\"))
{
str += _T("\\");
}
CString strIniFile = str + _T("conf.ini"); // 配置文件名
CFile iniFile;
if(!myfile.Open(strPath.GetString(), CFile::modeWrite))//写文件
{
return;
}
CString strYourData = _T("你想写入的数据");
iniFile.Write(strYourData.GetString(), strYourData.GetLength());
iniFile.Close();
}
ofstream outFile(file_path,ios::out); // file_path是文件路径
if (outFile)
{
CString str;
outFile.write(str.GetBuffer() ,str.GetLength());
outFile.close();
}