查看: 2400|回复: 0

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

[复制链接]

4

主题

3

回帖

40

积分

管理员

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

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

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

×
Technique  + M& C2 T4 S9 \, G, R. ^, r
On the client side use the vault control to write to a text file.
" A( i9 ?- E5 B) `% h  ^9 aJavaScript  7 o0 p4 O2 t6 z) w
with (top.aras.vault)
/ z; i( R- D! b" _5 d; ?{
/ I- b) [% z1 ?6 }/ V8 }  fileCreate(filePath);
0 P3 P' P9 n8 O: p6 W1 Q3 S! l  fileOpenAppend(filePath);
6 e, G; f8 b4 n. q& R  fileWriteLine('<AML><Item type="MyItemType"/></AML>');
. |. x( S" ]0 @  fileClose(); 1 _+ \" d8 {2 [3 N( \; T* a4 j9 v
}
& ?- M$ A6 z: E3 @Technique  
1 n- Y7 I; K- R# H; z8 v9 ]* hOn the server side use the File and StreamWriter namespaces to write to a text file.
- ?5 u+ h: j" x" yC#  - r! O8 T2 G1 ]8 g' H
Innovator myInnovator = this.newInnovator();
7 d5 H( D7 v! c' x  [ # n/ J9 P5 V1 @9 l; k7 H  n( I
// Save the results to a file.
0 ^( N2 K, u+ J$ }! P/ `. {string path = myInnovator.MapPath("temp/yoyo.txt");
* y1 G* q1 X- R. o6 g% stry # l+ _1 Q& t5 Q# U
{
; N1 l7 B! L' u. h  if (File.Exists(path)) File.Delete(path);
% @0 F0 c$ P2 M0 r( Q1 i  StreamWriter sw = File.CreateText(path);
( J* w: h0 ~( V  sw.Write(this.dom.InnerXml);
  r1 C$ y$ L' b- {. @% t; K  sw.Close(); " k; I0 Q  ?/ }3 U
} ; V1 k4 s2 [! J' r& c0 V. P
caTCh (Exception e)
( H9 P5 k: D1 V; v0 S/ c' m{
7 R- Z' Q4 D$ A' N4 n. \  return myInnovator.newError(e.Message); 7 x* y& V+ P, `) d( Y
} & L8 f9 h; ^3 x" t9 e+ r
return myInnovator.newResult("ok");
5 W# ]9 i& P& I  k: X
. a+ a' Y* \0 c. ^1 z& m  ?2 J( d
上海点团信息科技有限公司,承接UG NX,CATIA,CREO,Solidworks 等CAx软件,Teamcenter,3D Experience等PLM软件,工业4.0数字化软件的实施\二次开发\培训相关业务,详情QQ 939801026 Tel 18301858168 网址 www.doteam.tech
回复

使用道具 举报

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

本版积分规则

在本版发帖
关注公众号
QQ客服返回顶部