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);
//
}
}
查看全文
相关阅读:
【openwrt】——lua字符串操作
Andriod绘图的基础知识
protect,public,private 的区别
fatjar 将项目使用的第三方jar包打包(亲测可用)
TPshop学习(8)微信支付
HTTP和HTTPS有什么区别? 什么是SSL证书?使用ssl证书优势?
LNMP安装Let’s Encrypt 免费SSL证书方法:自动安装与手动配置Nginx
腾讯云中ssL证书的配置安装
微信小程序:微信登陆(ThinkPHP作后台)
转载VC6LineNumberAddin 规格严格
原文地址:https://www.cnblogs.com/wqj1212/p/1020343.html
最新文章
Completely Uninstall MySQL Server
将log4j输出到rsyslog服务器
tmp目录删除和tmpwatch命令的使用
CentOS源码编译安装MySQL 5.5.15 | CentOS教程
SysLogHandler not writing to syslog with Python logging
ubuntu守护进程rsyslog.conf_栈_百度空间
A Logging System for Python
MySQL在Centos的卸载和安装 MySQL 红黑联盟
Centralized Logging Using Rsyslog
syslogng配置
热门文章
for line in sys.stdin
syslog介绍(二):Linux下syslog基本配置
how to get virtualenv working on DjangoStack?
Berkeley DB(六) DB Replication (HA)上部
MySQL查询优化:LIMIT 1避免全表扫描
应对LTE测试复杂化及成本挑战 非信令测试将成主流
最新基于adtbundlewindowsx86的android开发环境搭建
Qt基础——获取QGraphicsScene的缩略图即导出到图片
[置顶] 给出洗牌的一个算法,并将洗好的牌存储在一个整形数组里。(思路2)
正则表达式速查表
Copyright © 2011-2022 走看看