zoukankan
html css js c++ java
打开文件,保存文件
打开指定路径下文件
void
CGFileCompileDlg::OnButtonOpen()
{
//
TODO: Add your control notification handler code here
/**/
/*
*********************************************************************************
*/
CFile openfile;
int
iFileLength;
char
*
lpGCodeBuffer;
//
G代码数据的存储区
//
CString msg="文件打开失败!";
CFileDialog fileopen(
true
,
"
.nc
"
, NULL, OFN_HIDEREADONLY
|
OFN_OVERWRITEPROMPT,
"
NC Files (*.NC)|*.NC|All Files (*.*)|*.*||
"
, NULL);
if
(fileopen.DoModal()
==
IDOK)
{
m_OpenPath.SetWindowText(fileopen.GetPathName());
if
(
!
openfile.Open(fileopen.GetPathName(), openfile.modeReadWrite
|
openfile.modeNoInherit, NULL))
{
this
->
MessageBox(
"
文件打开失败!
"
);
}
iFileLength
=
openfile.GetLength();
lpGCodeBuffer
=
new
char
[iFileLength
+
1
];
//
根据文件的长度创建G代码存储区
openfile.Read(lpGCodeBuffer, iFileLength);
//
将G代码显示在编辑框中
lpGCodeBuffer[iFileLength]
=
'
\0
'
;
m_Para
=
lpGCodeBuffer;
delete lpGCodeBuffer;
openfile.Close();
UpdateData(FALSE);
}
/**/
/*
else
{
MessageBox(msg);
}
*/
}
保存文件
void
CGFileCompileDlg::OnButtonSave()
{
//
TODO: Add your control notification handler code here
/**/
/*
***************************************************************************
*/
//
CString msg="文件保存失败!请检查路径是否正确!";
CFile savefile;
char
*
lpGCodeBuffer;
//
G代码数据的存储区
int
iFileLength;
CFileDialog fileopen(
false
,
"
.nc
"
, NULL, OFN_HIDEREADONLY
|
OFN_OVERWRITEPROMPT,
"
NC Files (*.NC)|*.NC|All Files (*.*)|*.*||
"
, NULL);
if
(fileopen.DoModal()
==
IDOK)
{
m_SavePath.SetWindowText(fileopen.GetPathName());
UpdateData(
true
);
if
(
!
savefile.Open(fileopen.GetPathName(), savefile.modeWrite
|
savefile.modeCreate, NULL))
{
this
->
MessageBox(
"
文件保存失败!
"
);
}
//
保存G文件
iFileLength
=
m_Para.GetLength();
lpGCodeBuffer
=
new
char
[iFileLength
+
1
];
//
根据文件的长度创建G代码存储区
strcpy(lpGCodeBuffer,m_Para);
lpGCodeBuffer[iFileLength]
=
'
\0
'
;
savefile.Write(lpGCodeBuffer,iFileLength);
delete lpGCodeBuffer;
savefile.Close();
UpdateData(
false
);
}
//
else
//
{
//
MessageBox(msg);
//
}
}
查看全文
相关阅读:
11.8-ros-navigation解析
8.14-rqt_common_pluggins 详解
8.1-roscomm详解
8.15-ros-bag使用
7.26-rosbridge-suit 解读
7.26-roscpp_overview详解
7.26-ROS其他有价值模块
java dbutils查询数据库时无法给部分字段赋值原因
java_获取多个文件夹下所有.java源码的总行数
正则表达式-1-初识正则表达式
原文地址:https://www.cnblogs.com/wqj1212/p/1020343.html
最新文章
P1063 能量项链 区间DP
多边形游戏 DP
[hdu 6352] Call It What You Want
[cf 1140] G. Double Tree
[cf 1139] F. Dish Shopping
[cf 1136] E. Nastya Hasn't Written a Legend
计算几何学习笔记
面试中的工具问题 看这一篇就够了
python基础练习题3
python基础练习题2
热门文章
python模块与包的详解
python文件读写详解
python字典总结
python基础练习题1
python类和self解析
和面试官面对面——接口测试篇
jemter简单测试方式
12.4-ROS激光
12.3-ros遥操作teleop
11.10-改造ARIA和move_base: action-mode and planning model
Copyright © 2011-2022 走看看