by Himanshu sharma (1 Submission)
Category: Miscellaneous
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Thu 27th May 2004
Date Added: Mon 8th February 2021
Rating: (1 Votes)
through three ways u can rename the file and folder
API Declarations
Add three command buttons
ByVal lpExistingFileName As String, _
ByVal lpNewFileName As String) As Long
Private Sub Command2_Click()
Dim lRet As Long
'Move the folder on same path but u have to change the name of folder
lRet = MoveFile("D:\Hook1", "D:\Hook")
If lRet = 0 Then MsgBox "Can't Rename or move the folder"
'Move the File on same path but u have to change the name of Filename
MoveFile "D:\spy1.txt", "D:\Hook1.txt"
If lRet = 0 Then MsgBox "Can't Rename or move the file"
End Sub
Private Sub Command1_Click()
Dim fso As New FileSystemObject
'Move the folder on same path but u have to change the name of folder
fso.MoveFolder "D:\Hook", "D:\Hook1"
'Move the File on same path but u have to change the name of Filename
fso.MoveFile "D:\Hook.txt", "D:\Hook1.txt"
Set fso = Nothing
End Sub
Private Sub Command3_Click()
'This is the vb command 'Reanme the Foder
Name "D:\Hook" As "D:\Hook1"
'Rename the file
fso.MoveFile "D:\Hook.txt", "D:\Hook1.txt"
End Sub