我希望能夠從存儲在文本文件中的列表中創建新文件夾。 的名稱存儲像來自列表中的新文件夾,來自vb.net中的文本文件
test1
test2
test3
所以到目前爲止我的代碼,將存儲在另一個文本文件來創建新的文件夾的路徑,(這是在給定的父文件夾的最古老的文件夾)「Foldercreation.txt」
然後用我想創建的文件夾的名稱「Folderstocreate.txt」打開文件,並將它們全部存儲在filereader2中。
但是當試圖爲每一行創建文件夾時什麼也沒有發生。
我現在的代碼;
Dim fileReader, filereader2 As System.IO.StreamReader
Dim stringreader, parfolder As String
Dim path, foldername As List(Of String)
Dim count As Byte
If MsgBox("Are you sure you want to create these folders?,
Before clicking yes, make sure EVERYONE is out of paperport & you have entered the correct numbers.", MsgBoxStyle.YesNo, "WARNING!") = MsgBoxResult.Yes Then
If strnumbx.Text = "" Then
MsgBox("You have not entered a start number for the folders.", MsgBoxStyle.OkOnly, "Error")
End If
'Loads a text file at the given location, to read to.
fileReader = My.Computer.FileSystem.OpenTextFileReader("C:\Data\Test\Foldercreation.txt")
'Set stringreader as the read line from the file
stringreader = fileReader.ReadLine()
path = System.IO.Directory.GetDirectories(stringreader).ToList
path.Sort()
count = path.Count - 1
parfolder = path(count)
'System.IO.Directory.CreateDirectory(parfolder & "\test")
filereader2 = New StreamReader("C:\Data\Test\Folderstocreate.txt", True)
filereader2.ReadToEnd()
For Each line In filereader2.ReadToEnd()
System.IO.Directory.CreateDirectory(parfolder & fileReader.ReadToEnd(count - 1))
count = count + 1
Next
End If
fileReader.Close()
filereader2.Close()
您正在使用'ReadAllLine',但您說您的值由空格分隔。這是什麼? – Mederic
這個網站改變了格式,他們在不同的線路 –