WCHAR szDir[MAX_PATH];
BROWSEINFO bi;
ITEMIDLIST *pidl;
bi.hwndOwner = this->m_hWnd;
bi.pidlRoot = NULL;
bi.pszDisplayName = szDir;
bi.lpszTitle = L"请选择目录";
bi.ulFlags = BIF_RETURNONLYFSDIRS;
bi.lpfn = NULL;
bi.lParam = 0;
bi.iImage = 0;
pidl = SHBrowseForFolder(&bi);
if (pidl == NULL)
return;
CString fineName = L"11.txt"; //指定文件名
if (SHGetPathFromIDList(pidl, szDir))
{
CString m_strSavePath;
m_strSavePath.Format(L"%s", szDir);
fineName = m_strSavePath + "\\" + fineName; //完整路径
}
//测试
std::ofstream out;
out.open(fineName, ios::in | ios::out | ios::binary);
if (out.is_open())
{
out << "This is a line.\n";
out << "This is another line.\n";
out.close();
}
else
{
return;
}
打开指定路径下的txt文件
最新推荐文章于 2024-11-04 09:49:03 发布