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);
//
}
}
查看全文
相关阅读:
整型变量修饰符,char类型数据存储原理,字节数,
进制
C语言的数据、常量和变量
递归函数
函数,#include <>和#include " "区别
分支语句
hdu_1015(dfs)
基本数论
基础几何
hdu_1018(斯大林公式/n!的位数)
原文地址:https://www.cnblogs.com/wqj1212/p/1020343.html
最新文章
【USACO 2.2.2】集合
【USACO 2.2.1】序言页码
【USACO 2.1.5】海明码
【USACO 2.1.4】荷斯坦奶牛
【USACO 2.1.3】三值的排序
【USACO 2.1.2】法雷序列
【USACO 2.1.1】城堡
hdu 3333 Turing Tree (树状数组+离线处理+离散化)
2015 多校 #5 1007 MZL's simple problem
2015 多校 #5 1005 MZL's chemistry
热门文章
2015多校 #5 1002 MZL's xor
hdu 4267/poj 3468 A Simple Problem with Integers (分状态的树状数组)
hdu 3584 Cube (三维树状数组,更新区间,查询单点)
poj 2155- Matrix (树状数组,二维,更新区间,查询单点)
hdu 1556Color the ball (树状数组,更新区间,查询单点)
sgu 180
hdu 1166 敌兵布阵 (树状数组)
C语言-字符串
C语言算法
C语言数组
Copyright © 2011-2022 走看看