Private Sub Test_AutoRenameFilesStoredInAFolderWithDateStampPrefixAdded()
Dim FP As String
FP = "E:\WeiJin Tang\Testing Folder"
Dim myDirectoryInfo As IO.DirectoryInfo
myDirectoryInfo = New IO.DirectoryInfo(FP)
Dim myFileInfos() As IO.FileInfo
myFileInfos = myDirectoryInfo.GetFiles("*.txt")
Dim FI As IO.FileInfo
Dim SequenceNumberOfCodeTesting As Integer
For Each FI In myFileInfos
Dim FPFN As String
FPFN = FI.FullName
Dim FS As IO.FileStream
FS = New IO.FileStream(FPFN, IO.FileMode.Open, IO.FileAccess.Read)
'FS = New IO.FileStream(FPFN, IO.FileMode.CreateNew)
Dim SR As IO.StreamReader
SR = New IO.StreamReader(FS)
Dim T As String
T = SR.ReadToEnd
Dim RecognizedDateAsOneString As String
Dim H As WjDateRecognizer_Dot_Y2008M04D03
H = New WjDateRecognizer_Dot_Y2008M04D03(T)
RecognizedDateAsOneString = H.GetRecognizedDateAsOneString()
SR.Close()
FS.Close()
Dim FPFNWithDateStamp As String
SequenceNumberOfCodeTesting += 1
Dim PathToOutputFolder As String
PathToOutputFolder = FI.DirectoryName & IO.Path.DirectorySeparatorChar & "Files with DateStamp"
IO.Directory.CreateDirectory(PathToOutputFolder)
FPFNWithDateStamp = IO.Path.Combine(PathToOutputFolder, "[" & RecognizedDateAsOneString & "] " & Now.Ticks & " " & FI.Name)
IO.File.Copy(FPFN, FPFNWithDateStamp)
Next
End Sub
' - - - - - - - - - - - - -
' - - - - - - - - - - - - -
沒有留言:
張貼留言