Wednesday, May 23, 2007

C++ File Open, save in .Net Compact Framework

Since we are talking about folder browsing, we can review how to do file saving and opening.

First, small device...

void CXXDlg::OnBnClickedBtnConfig()
{
// TODO: Add your control notification handler code here

TCHAR tFileName[MAX_PATH+1] = TEXT("\0");

OPENFILENAME ofn;
memset(&ofn, 0, sizeof(ofn));
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = this->m_hWnd;
ofn.lpstrFile = tFileName;
ofn.lpstrFilter = TEXT("Cam Config\0*.c2t\0All Files (*.*)\0*.*\0");
ofn.nFilterIndex = 0;
ofn.nMaxFile = MAX_PATH;
ofn.lpstrInitialDir = TEXT("\\SystemCF");
ofn.lpstrTitle = TEXT("Cam Config File Open Dialog");
ofn.Flags = OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST;
ofn.lpstrDefExt = TEXT("c2t");

GetOpenFileName(&ofn);

sStatus.Format(_T("%s"),tFileName );
UpdateData(FALSE);

}

similar, GetSaveFileName(..)..

No comments: