首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在txt列表中追加每一行

在txt列表中追加每一行
EN

Stack Overflow用户
提问于 2011-08-17 11:53:08
回答 1查看 355关注 0票数 0

我有一份文件名列表,地址如下:

c:\ICT\AUTOCAD_2010\Customisations\20090409\20090409.lsp c:\ICT\AUTOCAD_2010\Customisations\Advanced偏移\LSP\高级OFFSET.lsp c:\ICT\AUTOCAD_2010\Customisations\Advanced c:\ICT\AUTOCAD_2010\LSP\acad2010doc.lsp

这份清单是非常基本的,但应附加如下:

加载“c:\ICT\AUTOCAD_2010\Customisations\20090409\20090409.lsp”) (加载“c:\ICT\AUTOCAD_2010\Customisations\Advanced偏移\LSP\高级OFFSET.lsp”) (load“c:\ICT\AUTOCAD_2010\Customisations\LockDWG\LSP\LockDWG.lsp”) (load“c:\ICT\AUTOCAD_2010\LSP\acad2010doc.lsp”)

如何使用VB.net来完成这一任务?

EN

回答 1

Stack Overflow用户

发布于 2011-08-17 16:08:57

如果您的文件不太大,则可以执行以下操作:

代码语言:javascript
复制
Dim fileContents As String, contentArray As String()
Dim updateContents As New StringBuilder("")

'read the file contents in
fileContents = My.Computer.FileSystem.ReadAllText("C:\TestInput.txt")
'split the contents on the space delimiter - this method will fail if you have a space in your filename
contentArray = fileContents.Split(" "c)
'loop through each file found in the data and format as required
For Each fileString As String In contentArray
    updateContents.Append(String.Format("(load {0}{1}{0}) ", Chr(34), fileString))
Next
'write out the newly formatted file
My.Computer.FileSystem.WriteAllText("C:\TestOuput.txt", updateContents.ToString, True)
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/7092362

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档