can anyone help me with this? im having trouble with renaming a file.. the last 2 digit of DT102T01 up to DT102T15 will count according to the number of files inside the Data_PRN folder. please help! any suggestion will be appreciated.. tnx
'===== make directory & rename file . prn to .txt =======
Dim PRNname As String
Dim TXTname As String
Dim MakeDirectory As String = "C:\CHRONOLOG"
If System.IO.File.Exists(MakeDirectory) = True Then
MsgBox("Folder already exist", vbInformation, )
End If
Dim md As System.IO.DirectoryInfo = CreateDirectory(MakeDirectory)
MsgBox("File/Folder created")
Console.WriteLine("File/Folder created at {0}", System.IO.File.GetCreationTime(MakeDirectory))
mdcount = 1
directoryCount = System.IO.Directory.GetFiles("C:\Data_PRN\", "*.*", IO.SearchOption.AllDirectories).Length()
Dim CopyFile As String
Dim PasteFile As String
CopyFile = "C:\Data_PRN"
PasteFile = "C:\CHRONOLOG\"
If Not My.Computer.FileSystem.FileExists(CopyFile) = True Then
My.Computer.FileSystem.CopyDirectory(CopyFile, PasteFile)
MsgBox("Files copied")
Else
MsgBox("Already exists")
End If
'Dim Sfile As String = "C:\DT102T*" & mdcount & ".prn"
' Dim Sfile As String = Dir(PathName:="C:\Data_PRN\DT102T*" & mdcount & ".prn", Attributes:=FileAttribute.Normal)
Do While mdcount <= directoryCount
PRNname = "C:\Data_PRN\DT102T*" & mdcount & ".prn"
[B][COLOR="Red"]TXTname = "C:\CHRONOLOG\DT102T*" & mdcount & ".txt"[/COLOR][/B]
Rename(PRNname, TXTname)
mdcount += 1
Loop