Bonjour,
Je cherche à effacer un fichier avec SHFILEOPSTRUCTsuivant l'exemple de ce site mais il m'affiche un message d'erreur : impossible de supprimer fichier : impossible de lire à partir du fichier ou de la disquette source.
Voici le code et merci de votre aide
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39 Private Type SHFILEOPSTRUCT hwnd As Long wFunc As Long pFrom As String pTo As String fFlags As Long fAnyOperationsAborted As Long hNameMappings As Long lpszProgressTitle As String End Type Private Const FO_DELETE As Long = &H3 Private Const FOF_ALLOWUNDO As Long = &H40 Private Declare Function SHFileOperation Lib "Shell32.dll" Alias "SHFileOperationA" _ (lpFileOp As SHFILEOPSTRUCT) As Long Public Function DansCorbeille() As Boolean Dim DelFileOp As SHFILEOPSTRUCT Dim Result As Long With DelFileOp .hwnd = Me.hwnd .wFunc = FO_DELETE .pFrom = "e:\abc.txt" .fFlags = FOF_ALLOWUNDO End With Result = SHFileOperation(DelFileOp) DansCorbeille = (Result = 0) And (DelFileOp.fAnyOperationsAborted = 0) End Function Private Sub Command1_Click() MsgBox (DansCorbeille) End Sub
Partager