-
hi,
i would like to know a way through a button that i can rename a file to another name.
e.g.
system.ini to systemwin.ini, and also detect weather systemwin.ini is present if it is rename a different file
thanks for any help, please could you include some code
Cheers
Merlin ?
-
Code:
Private Sub Command1_Click()
Name "C:\Windows\System.ini" As "C:\Windows\Systemwin.ini"
If Dir("C:\Windows\Systemwin.ini") <> "" Then
Msgbox "File has been renamed!"
Else
Msgbox "An error has occured!", vbCritical, Error$
End If
-
<?>
Code:
Option Explicit
Private Sub Form_Load()
On Error GoTo errhandle:
Dim sold As String, snew As String
Dim sDir As String
sDir = "C:\my documents\"
sold = sDir & "mytext.txt"
snew = sDir & "smynewfile.txt"
'see if the new file name already exist
If Dir(snew) <> "" Then MsgBox "File Exists Already"
Name sold As snew
errhandle:
'if the file doesn't exist
If Err.Number = 53 Then MsgBox "Sorry, file does not exist."
End Sub
-
thanks guys that is just what i needed,
Merlin ?