cs_fred2019
Messages postés20Date d'inscriptionmardi 10 avril 2007StatutMembreDernière intervention25 mai 2007
-
24 mai 2007 à 13:40
cs_fred2019
Messages postés20Date d'inscriptionmardi 10 avril 2007StatutMembreDernière intervention25 mai 2007
-
25 mai 2007 à 01:18
j'aimerais savoir comment copier un fichier dans un repertoir , j'ai codé ceci mais cela fonctionne pas!
pseudoOM
Messages postés173Date d'inscriptionjeudi 3 février 2005StatutMembreDernière intervention30 janvier 20091 24 mai 2007 à 14:04
Est ce que ceci ne fonctionnerais pas tout simplement :
FileCopy "c:" + str_SFichier, "c:" + str_DFichier
' str_SFichier --> Chemin fichier source
' str_DFichier --> Chemin de destination
pseudoOM
Vous n’avez pas trouvé la réponse que vous recherchez ?
anto37_44
Messages postés48Date d'inscriptionmardi 3 avril 2007StatutMembreDernière intervention11 juin 20071 24 mai 2007 à 14:20
salut
si j'ai bien compris ce que tu veux, ceci devrait t'aider :
Private Sub Command1_Click()
resultat = copier(Text1.Text, Text2.Text)
If resultat = "OK" Then
MsgBox "Le fichier a été copié avec succés !"
Else
MsgBox "Le fichier n'a pas été copié pour cause d'erreur"
End If
avec en Text1.Text l'adresse complète de ton fichier original et en Text2.Text l'adresse complète de ta copie
anto37_44
Messages postés48Date d'inscriptionmardi 3 avril 2007StatutMembreDernière intervention11 juin 20071 24 mai 2007 à 15:26
Oups je suis en train de voir que j'ai oublier la motié du code:
Public Const FO_COPY = &H2
Public Const FO_DELETE = &H3
Public Const FO_MOVE = &H1
Public Const FO_RENAME = &H4
Public Const FOF_CONFIRMMOUSE = &H2
Public Const FOF_ALLOWUNDO = &H40
Public Const FOF_FILESONLY = &H80
Public Const FOF_MULTIDESTFILES = &H1
Public Const FOF_NOCONFIRMATION = &H10
Public Const FOF_NOCONFIRMMKDIR = &H200
Public Const FOF_NO_CONNECTED_ELEMENTS = &H1000
Public Const FOF_NOCOPYSECURITYATTRIBS = &H800
Public Const FOF_NOERRORUI = &H400
Public Const FOF_RENAMEONCOLLISION = &H8
Public Const FOF_SILENT = &H4
Public Const FOF_SIMPLEPROGRESS = &H100
Public Const FOF_WANTMAPPINGHANDLE = &H20
Public Const FOF_WANTNUKEWARNING = &H2000
Public Const FOF_NORECURSION = &H1000 '// don't recurse into directories.
Public Type SHFILEOPSTRUCT
hWnd As Long
wFunc As Long
pFrom As String
pTo As String
fFlags As Integer
fAnyOperationsAborted As Long
hNameMappings As Long
lpszProgressTitle As String
End Type
Public Declare Sub CopyMemory Lib "kernel32.dll" Alias "RtlMoveMemory" _
(Dest As Any, Sourc As Any, ByVal Length As Long)
Public Declare Function SHFileOperation Lib "shell32.dll" Alias "SHFileOperationA" _
(lpFileOp As Any) As Long
Public Function copier(FROM As String, copie As String)
On Error GoTo erreur
Dim fso, msg
Set fso = CreateObject("Scripting.FileSystemObject")
If Not fso.FileExists(FROM) Then 'on verifie si le fichier existe
copier = "Le fichier n'existe pas"
Exit Function
erreur:
copier = "Une erreur c'est produite"
Exit Function
End If
Dim fos As SHFILEOPSTRUCT ' structure to pass to the function
Dim retval As Long ' return value
With fos
.hWnd = 0 'ou Me.hWnd si on a une Feuille par exemple .wFunc FO_COPY 'Action Copie
.pFrom = FROM & vbNullChar 'Source path
.pTo = copie & vbNullChar 'Dest Path
.fFlags = FOF_NOCONFIRMMKDIR Or FOF_WANTMAPPINGHANDLE 'Flags de Copie
.fAnyOperationsAborted = 0
.hNameMappings = 0
.lpszProgressTitle = vbNullChar
End With
retval = SHFileOperation(fos)
copier = "OK"
End Function
cs_casy
Messages postés7741Date d'inscriptionmercredi 1 septembre 2004StatutMembreDernière intervention24 septembre 201440 24 mai 2007 à 21:11
C'est quoi cette usine à gaz que tu nous fais anto ?????
Fred, que représente pour toi, le point dans ".\machines"
???????
Si c'est le répertoire de l'executable, il faut faire rep = Application.StartupPath & "\machines" & num_interne.Text
Si c'est le répertoire en cours d'utilisation à ce moment précis, c'est rep = Environment.CurrentDirectory & "\machines" & num_interne.Text
---- Sevyc64 (alias Casy) ----<hr size="2" width="100%" /># LE PARTAGE EST NOTRE FORCE #