将每一行追加到 txt 列表中

发布于 2024-11-30 01:25:45 字数 635 浏览 0 评论 0原文

我有一个文件名列表和位置如下:

c:\ICT\AUTOCAD_2010\Customizations\20090409\20090409.lsp c:\ICT\AUTOCAD_2010\Customizations\高级偏移\LSP\ADVANCED OFFSET.lsp c:\ICT\AUTOCAD_2010\Customizations\LockDWG\LSP\LockDWG.lsp c:\ICT\AUTOCAD_2010\LSP\acad2010doc.lsp

该列表非常基本,但应附加说明:

(加载“c:\ICT\AUTOCAD_2010\Customizations\20090409\20090409.lsp”) (加载“c:\ICT\AUTOCAD_2010\Customizations\Advanced Offset\LSP\ADVANCED OFFSET.lsp”) (加载“c:\ICT\AUTOCAD_2010\Customizations\LockDWG\LSP\LockDWG.lsp”) (加载“c:\ICT\AUTOCAD_2010\LSP\acad2010doc.lsp”)

如何使用 VB.net 完成此操作?

I have a list of file names and there locations as follows:

c:\ICT\AUTOCAD_2010\Customisations\20090409\20090409.lsp
c:\ICT\AUTOCAD_2010\Customisations\Advanced Offset\LSP\ADVANCED
OFFSET.lsp c:\ICT\AUTOCAD_2010\Customisations\LockDWG\LSP\LockDWG.lsp
c:\ICT\AUTOCAD_2010\LSP\acad2010doc.lsp

The list is very basic but should be appended to say:

(load “c:\ICT\AUTOCAD_2010\Customisations\20090409\20090409.lsp”)
(load “c:\ICT\AUTOCAD_2010\Customisations\Advanced Offset\LSP\ADVANCED OFFSET.lsp”)
(load “c:\ICT\AUTOCAD_2010\Customisations\LockDWG\LSP\LockDWG.lsp”)
(load “c:\ICT\AUTOCAD_2010\LSP\acad2010doc.lsp”)

How can this be done with VB.net?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

萝莉病 2024-12-07 01:25:45

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

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)

If your file is not too large then you can do the following:

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)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文