PLM之家PLMHome-工业软件践行者

【Aras二次开发源码】如何将文本存成文件

[复制链接]

2018-8-1 14:06:14 2355 0

2470

主题

1275

回帖

8万

积分

管理员

PLM之家站长

积分
82172
QQ
发表于 2018-8-1 14:06:14 | 显示全部楼层 |阅读模式

请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!

您需要 登录 才可以下载或查看,没有账号?注册

x
Technique  / `9 B2 X3 l' \+ |1 q& ?  L
On the client side use the vault control to write to a text file. " U( s* M! U" K
JavaScript  3 G+ |" \. [) ?7 G! l$ c; y
with (top.aras.vault)
" Y2 {& `" G  R{ ; x. Z1 x4 W" o
  fileCreate(filePath); ' e8 `8 y, c3 }% M7 F
  fileOpenAppend(filePath);
$ y8 d) }/ n* e/ y  C8 P1 ]  fileWriteLine('<AML><Item type="MyItemType"/></AML>');   W) k1 r* C; V% ?0 y
  fileClose(); * ?# A5 e, \( `4 I/ Q3 N6 p
} 4 w! w' G9 n: z( W: L: C* u: V+ a
Technique  . F* r9 J6 b  S" o& l
On the server side use the File and StreamWriter namespaces to write to a text file. * `4 ]2 u* X9 _! G
C#  
1 P- U( R  ^+ l, OInnovator myInnovator = this.newInnovator(); 0 N0 T9 p- O5 ?+ P

6 h/ E$ a6 B3 I// Save the results to a file.
2 z9 j" J+ j' O& J( e- \( tstring path = myInnovator.MapPath("temp/yoyo.txt"); 9 Y, T. m, Q) c5 N5 X8 v  g% f4 @
try : M" c5 C' @+ E7 o7 d( ^# j
{
1 }% x4 d/ J0 \0 K  E1 E  if (File.Exists(path)) File.Delete(path);
1 t# z( B3 O1 v. P$ C  StreamWriter sw = File.CreateText(path);
) V' Z1 [1 b+ [2 Z  sw.Write(this.dom.InnerXml); : n7 ^  s# }9 K0 i, w! `8 T# a
  sw.Close(); 5 {! L1 D/ Q. w* ]
} - t2 s7 R! e2 T0 i4 ]0 T
caTCh (Exception e) " a2 L6 k5 x! j2 \; c5 ?
{ / [8 ?( ?' B: U) T' d
  return myInnovator.newError(e.Message); 4 L& R: D  b+ L3 G: P6 _* O6 d
}
& e( b2 [' U% q+ S, Creturn myInnovator.newResult("ok"); $ l9 n& E( Z1 v2 D* i

; _) A1 @7 c* R  X: s4 D( Q2 J
上海点团信息科技有限公司,承接UG NX,CATIA,CREO,Solidworks 等CAx软件,Teamcenter,3D Experience等PLM软件,工业4.0数字化软件的实施\二次开发\培训相关业务,详情QQ 939801026 Tel 18301858168 网址 doTeam.tech
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 注册

返回列表 本版积分规则

  • 发布新帖

  • 在线客服

  • 微信

  • 客户端

  • 返回顶部

  • x
    温馨提示

    本网站(plmhome.com)为PLM之家工业软件学习官网站

    展示的视频材料全部免费,需要高清和特殊技术支持请联系 QQ: 939801026

    PLM之家NX CAM二次开发专题模块培训报名开始啦

    我知道了