0
我一直在使用下面的代碼將我的文本文件分割成兩個文件。我的原始文件只包含20線,我試圖分裂成2個文件。即使當該腳本運行,我得到的消息在最後說,過程是完整的,我看不到任何分裂的文件在輸出location.Please告訴我什麼是代碼中的問題;我是新的VBScript所以請幫助我。感謝提前:)沒有得到輸出分裂文本文件在VBScript
Dim Counter
Const InputFile = "C:\Cs.txt"
Const OutputFile = "C:\Users\rmehta\Desktop"
Const RecordSize = 10
Const ForReading = 1
Const ForWriting = 2
Const ForAppending = 8
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile (InputFile, ForReading)
Counter = 0
FileCounter = 0
Set objOutTextFile = Nothing
Do Until objTextFile.AtEndOfStream
if Counter = 0 Or Counter = RecordSize Then
Counter = 0
FileCounter = FileCounter + 1
if Not objOutTextFile is Nothing then objOutTextFile.Close
Set objOutTextFile = objFSO.OpenTextFile(OutputFile & "_" & FileCounter & ".txt", ForWriting, True)
end if
strNextLine = objTextFile.Readline
objOutTextFile.WriteLine(strNextLine)
Counter = Counter + 1
Loop
objTextFile.Close
objOutTextFile.Close
Msgbox "Split process complete"
與保持cnSize = 11的小變化...非常感謝!非常有用:) – M3HTA
請幫我這個:http://stackoverflow.com/q/18722318/2636830 – M3HTA
在此先感謝:) – M3HTA