内容简介:我有一个名为’data’的变量我需要写入一个名为“listfile.txt”的文本文件.你能告诉我vbscript翻译自:https://stackoverflow.com/questions/3117121/reading-and-writing-value-from-a-textfile-by-using-vbscript-code
我有一个名为’data’的变量我需要写入一个名为“listfile.txt”的文本文件.你能告诉我vbscript
来写
Set objFileToWrite = CreateObject("Scripting.FileSystemObject").OpenTextFile("C:\listfile.txt",2,true) objFileToWrite.WriteLine(data) objFileToWrite.Close Set objFileToWrite = Nothing
OpenTextFile参数:
<filename>, IOMode (1=Read,2=write,8=Append), Create (true,false), Format (-2=System Default,-1=Unicode,0=ASCII)
阅读整个文件
Set objFileToRead = CreateObject("Scripting.FileSystemObject").OpenTextFile("C:\listfile.txt",1) strFileText = objFileToRead.ReadAll() objFileToRead.Close Set objFileToRead = Nothing
逐行阅读
Set objFileToRead = CreateObject("Scripting.FileSystemObject").OpenTextFile("C:\listfile.txt",1) Dim strLine do while not objFileToRead.AtEndOfStream strLine = objFileToRead.ReadLine() 'Do something with the line loop objFileToRead.Close Set objFileToRead = Nothing
翻译自:https://stackoverflow.com/questions/3117121/reading-and-writing-value-from-a-textfile-by-using-vbscript-code
以上所述就是小编给大家介绍的《使用vbscript代码从文本文件中读取和写入值》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!
猜你喜欢:- golang 创建,读取,写入文件
- 第十五篇:SQL注入读取、写入文件
- go语言csv文件的读取与写入
- golang读取xls写入到xlsx中
- 《从0到1学习Flink》—— Flink 读取 Kafka 数据批量写入到 MySQL
- R0Ak:一款针对Windows 10的内核模式代码读取、写入和执行的测试工具
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
JavaScript: The Definitive Guide, 5th Edition
David Flanagan / O'Reilly Media / 2006-08-01 / USD 49.99
This Fifth Edition is completely revised and expanded to cover JavaScript as it is used in today's Web 2.0 applications. This book is both an example-driven programmer's guide and a keep-on-your-desk ......一起来看看 《JavaScript: The Definitive Guide, 5th Edition》 这本书的介绍吧!