VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



through three ways u can rename the file and folder

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

Rate through three ways u can rename the file and folder



     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


Download this snippet    Add to My Saved Code

through three ways u can rename the file and folder Comments

No comments have been posted about through three ways u can rename the file and folder. Why not be the first to post a comment about through three ways u can rename the file and folder.

Post your comment

Subject:
Message:
0/1000 characters