2011-08-17 80 views
0

我有文件名列表,有地点如下:追加每行一个txt列表

C:\ ICT \ AUTOCAD_2010 \的定制\ 20090409 \ 20090409.lsp C:\ ICT \ AUTOCAD_2010 \的定制\高级胶印\ LSP \ ADVANCED OFFSET.lsp C:\ ICT \ AUTOCAD_2010 \的定制\ LockDWG \ LSP \ LockDWG.lsp C:\ ICT \ AUTOCAD_2010 \ LSP \ acad2010doc.lsp

名单是非常基本的,但应该附加说:

(负载“C:\ ICT \ AUTOCAD_2010 \的定制\ 20090409 \ 20090409.lsp”) (负载“C:\ ICT \ AUTOCAD_2010 \的定制\高级偏移\ LSP \ ADVANCED OFFSET.lsp”) (负载“C:\ ICT \ AUTOCAD_2010 \的定制\ LockDWG \ LSP \ LockDWG.lsp”) (载“C:\ ICT \ AUTOCAD_2010 \ LSP \ acad2010doc.lsp”)

怎么可以这样用VB做。净?

+0

是在一个文件中的原始列表?结果应该写入文件吗?或者你在使用其他数据结构吗? – 2011-08-17 13:05:24

回答

0

如果文件不是太大,那么你可以做到以下几点:

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)