TC官方合作论坛
标题:
为何写文件写了"\r\n",还是不能换行?有源码
[打印本页]
作者:
wfparkson
时间:
2014-4-24 13:05
标题:
为何写文件写了"\r\n",还是不能换行?有源码
我写了个写日志的函数,为何每次都不能换行,writefileline又会覆盖原来写的一行内容,下面是我的函数
//写日志函数
function writelog(strtxt)
var Path = C**t.ProPath //获取脚本路劲
ret=file.exist(Path&"Log\\")
if(!ret)
file.createfolder(Path&"Log\\")
endif
ret=file.exist(Path&"Log\\Log.txt")
if(!ret)
handle=file.createfile(Path&"Log\\Log.txt","rw")
if(handle==0)
return 0
endif
help.sleep(100)
file.writefileend("\r\n"&handle,system.getsystime(0)&" "&strtxt)
help.sleep(100)
file.closefile(handle)
return true
endif
handle=file.openfile(Path&"Log\\Log.txt")
if(handle==0)
return 0
endif
help.sleep(100)
file.writefileend("\r\n"&handle,system.getsystime(0)&" "&strtxt)
help.sleep(100)
file.closefile(handle)
return true
endfunction
最后实在没办法,只好用了writefileline函数,先用游标移动到文件末尾,再写入一行,实现了换行
file.setfilepostion(handle,"end")
file.writefileline(handle,system.getsystime(0)&" "&strtxt)
为何前面的代码实现不了呢,找不出问题
作者:
墨染年华
时间:
2014-4-24 13:16
需要先清空,或者在末尾加入
作者:
hualaosi
时间:
2014-4-24 15:43
你试试把"\r\n"放在你要写的内容后面试试?
欢迎光临 TC官方合作论坛 (http://bbs.52tc.co/)
Powered by Discuz! X3.1