我有一个包含以下内容的文件
aaaaaaaaa filename1.txt
bbbbbbbbbb filename2.dat
我想读取这个文件并将数据单独存储到相关文件中。
例如:- aaaaa ---> filename1.txt
有人可以告诉我这样做的方法吗?如果您有任何示例,那将是一个真正的帮助!
子主
Set ctlpath = "\\Download_Directory\CA.ctl"
Set subDirectory = "AUB"
Set MkrExtention = ".mkr"
ReadCtl(ctlpath,subDirectory,MkrExtention )
End Sub
Function ReadCtl(ctlFileName,ctlSubDirectory,MarkerFileExtension)
Const ForReading = 1
Const ForWriting = 2
Dim lineData,hashValue,fileName,fileToWrite
Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FileExists(ctlFileName) Then
Set objFile = objFSO.OpenTextFile(ctlFileName, ForReading)
Do Until objFile.AtEndOfStream
lineData = objFile.ReadLine
hashValue =Split(lineData," ") (0)
fileName =Split(lineData," ") (1)
WriteFileText("\\Download"+ctlSubDirectory+"
\"+fileName+MarkerFileExtension,hashValue)
Loop
objFile.Close
objFSO.Close
End If
ReadCtl = True
End Function
Function WriteFileText(sFilePath, sText)
Dim objFSO1 'As FileSystemObject
Dim objTextFile 'As Object
Set objFSO1 = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO1.CreateTextFile(sFilePath, True)
' Write hash data in to the file .mkr file
objTextFile.Write (sText)
objTextFile.Close
objFSO1.Close
End Function