CFile和CFileDialog的结合...

下面是一个函数可以使用CFileDialog取得文件路径,然后用CFile打开的.

注意,CFile( ***** , "txt", ".txt")这里这个*****要注意, TRUE为打开框, FALSE为另存为框.

(其中,m_szEditText是已经绑定到一个CEdit里面的CString)

CString m_szTmp;
char buf[1000];
CFileDialog dlg(TRUE,"mdl","*.mdl");
if(dlg.DoModal()==IDOK) {
CFile mfile;
mfile.Open(dlg.GetPathName(), CFile::modeRead);
mfile.Read(buf,sizeof(buf));
m_szTmp = buf;
m_szEditText = m_szTmp;
mfile.Close();
}
UpdateData(FALSE);

---------------------------------------------

CFileDialog Class Members

Data Members

m_ofnThe Windows OPENFILENAME structure. Provides access to basic file dialog box parameters.

Construction

CFileDialogConstructs a CFileDialog object.

Operations

DoModalDisplays the dialog box and allows the user to make a selection.
GetPathNameReturns the full path of the selected file.
GetFileNameReturns the filename of the selected file.
GetFileExtReturns the file extension of the selected file.
GetFileTitleReturns the title of the selected file.
GetNextPathNameReturns the full path of the next selected file.
GetReadOnlyPrefReturns the read-only status of the selected file.
GetStartPositionReturns the position of the first element of the filename list.

Overridables

OnShareViolationCalled when a share violation occurs.
OnFileNameOKCalled to validate the filename entered in the dialog box.
OnLBSelChangedNotifyCalled when the list box selection changes.
OnInitDoneCalled to handle the WM_NOTIFY CDN_INITDONE message.
OnFileNameChangeCalled to handle the WM_NOTIFY CDN_SELCHANGE message.
OnFolderChangeCalled to handle the WM_NOTIFY CDN_FOLDERCHANGE message.
OnTypeChangeCalled to handle the WM_NOTIFY CDN_TYPECHANGE message.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值