Hello, use this class and test if file exist ( function "existe") before
copy.
Function "deplace" will copy the file
Christophe VERGON
'---------------------------------------------------------------------------
------------
' Module : Nomfichier
' DateTime : 02/10/03 10:24
' Author : VERGON Christophe
' Purpose : File Name how to delete, copy, replace
'---------------------------------------------------------------------------
------------
Private mchemin As String
Private mnom As String
Private mextention As String * 3
Public Property Get chemin() As String
chemin = mchemin
End Property
Public Property Let chemin(ByVal vNewValue As String)
If Mid$(vNewValue, Len(vNewValue), 1) <> "\" Then
vNewValue = vNewValue & "\"
End If
mchemin = vNewValue
End Property
Public Property Get nomfichier() As String
nomfichier = mnom
End Property
Public Property Let nomfichier(ByVal vNewValue As String)
mnom = vNewValue
End Property
Public Property Get extention() As String
extention = mextention
End Property
Public Property Let extention(ByVal vNewValue As String)
mextention = vNewValue
End Property
Public Function existe() As Boolean
Dim a$
a$ = Dir(mchemin & mnom & "." & mextention)
If a$ = "" Then
existe = False
Else
existe = True
End If
End Function
Public Sub renomme(NewName As String)
Name mchemin & mnom & "." & mextention As mchemin & NewName & "." &
mextention
End Sub
Public Sub deplace(newpath As String)
If Mid$(newpath, Len(newpath), 1) <> "\" Then
newpath = newpath & "\"
End If
Name mchemin & mnom & "." & mextention As newpath & mnom & "." & mextention
End Sub
Public Sub CopieEtRenomme(NewName As String, ext As String)
Dim oldname As String
Dim newcompletename As String
On Error GoTo CopieEtRenomme_Error
oldname = mchemin & mnom & "." & mextention
newcompletename = mchemin & NewName & "." & ext
FileCopy oldname, newcompletename
On Error GoTo 0
Exit Sub
CopieEtRenomme_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure
CopieEtRenomme of Module de classe Nomfichier"
End Sub
Public Sub efface()
Dim n As String
n = mchemin & mnom & "." & mextention
Kill (n)
End Sub
Post by R-MHi
I've used following statement in VB6 and want to copy
and rename f1.txt
Private Sub Command1_Click()
m = Shell("copy c:\f1.txt d:\f2.txt", vbMaximizedFocus)
MsgBox "ok."
End Sub
"Runtime error 53: file not found."
how can I do it?
any help would be greatly appreciated.
--
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/