2011-08-17 78 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)