OVH Cloud OVH Cloud

Effacer un répertoire

8 réponses
Avatar
Patrice Henrio
J'ai utilisé le code que j'ai trouvé dans AllApi

Private Declare Function CreateDirectoryEx Lib "kernel32" Alias
"CreateDirectoryExA" (ByVal lpTemplateDirectory As String, ByVal
lpNewDirectory As String, lpSecurityAttributes As Any) As Long
Private Declare Function RemoveDirectory Lib "kernel32" Alias
"RemoveDirectoryA" (ByVal lpPathName As String) As Long
Private Sub Form_Load()
'KPD-Team 1999
'URL: http://www.allapi.net/
'E-Mail: KPDTeam@Allapi.net
'Create a new directory
CreateDirectoryEx "C:\Windows", "C:\KPD-Team", ByVal 0&
'remove the directory
RemoveDirectory "C:\KPD-Team"
End Sub

Cela marche bien pour créer un répertoire (même si je ne vois pas vraiment à
quoi sert le premier argument :
· lpTemplateDirectory
Points to a null-terminated string that specifies the path of the directory
to use as a template when creating the new directory.
Par contre le removeDirectory ne marche pas ?

Quelqu'un a-t'il une idée

8 réponses

Avatar
scraper
Bonjour Patrice Henrio, dans le message
news: u%
tu disais :

J'ai utilisé le code que j'ai trouvé dans AllApi

Private Declare Function CreateDirectoryEx Lib "kernel32" Alias
"CreateDirectoryExA" (ByVal lpTemplateDirectory As String, ByVal
lpNewDirectory As String, lpSecurityAttributes As Any) As Long
Private Declare Function RemoveDirectory Lib "kernel32" Alias
"RemoveDirectoryA" (ByVal lpPathName As String) As Long
Private Sub Form_Load()
'KPD-Team 1999
'URL: http://www.allapi.net/
'E-Mail:
'Create a new directory
CreateDirectoryEx "C:Windows", "C:KPD-Team", ByVal 0&
'remove the directory
RemoveDirectory "C:KPD-Team"
End Sub

Cela marche bien pour créer un répertoire (même si je ne vois pas
vraiment à quoi sert le premier argument :
· lpTemplateDirectory
Points to a null-terminated string that specifies the path of the
directory to use as a template when creating the new directory.
Par contre le removeDirectory ne marche pas ?



de tête, tu peux utiliser la cmde rmDir, mais il faut pour celà que ton
répertoire soit vide ...

sinon, vois du côté de SHFileOperation :
avec les bons flags (FOF_SILENT+FOF_NOCONFIRMATION) ça devrait le faire ...



--

Adresse invalide
Merci de répondre sur le forum ...
http://scraper.chez.tiscali.fr

scraper
Avatar
Patrice Henrio
"Patrice Henrio" a écrit dans le message de
news: u%
J'ai utilisé le code que j'ai trouvé dans AllApi

Private Declare Function CreateDirectoryEx Lib "kernel32" Alias
"CreateDirectoryExA" (ByVal lpTemplateDirectory As String, ByVal
lpNewDirectory As String, lpSecurityAttributes As Any) As Long
Private Declare Function RemoveDirectory Lib "kernel32" Alias
"RemoveDirectoryA" (ByVal lpPathName As String) As Long
Private Sub Form_Load()
'KPD-Team 1999
'URL: http://www.allapi.net/
'E-Mail:
'Create a new directory
CreateDirectoryEx "C:Windows", "C:KPD-Team", ByVal 0&
'remove the directory
RemoveDirectory "C:KPD-Team"
End Sub

Cela marche bien pour créer un répertoire (même si je ne vois pas vraiment
à quoi sert le premier argument :
· lpTemplateDirectory
Points to a null-terminated string that specifies the path of the
directory to use as a template when creating the new directory.
Par contre le removeDirectory ne marche pas ?

Quelqu'un a-t'il une idée



En fait une simple erreur de recopie du nom du répertoire.
Désolé.
Avatar
Patrice Henrio
Finalement rien de révolutionnaire et je crois même que certains en ont déjà
parler. C'est largement inspiré de l'équipe
'KPD-Team 1999

'URL: http://www.allapi.net/

'E-Mail:


Voici une procédure qui efface récursivement un répertoire

Public Sub EffaceRépertoire(CH As String)
Dim WFD As WIN32_FIND_DATA, hFile As Long, Fichier As String, Fichiers As
String, Fic() As String
Dim Cont As Boolean, N As Long
If Right(CH, 1) <> "" Then CH = CH & ""
Fichier = CH & "*"
Fichiers = ""
hFile = FindFirstFile(Fichier, WFD)
Cont = (hFile > 0)
Do While Cont
Fichier = StripNulls(WFD.cFileName)
If Fichier <> "." And Fichier <> ".." Then
If (GetFileAttributes(CH & Fichier) And
FILE_ATTRIBUTE_DIRECTORY) = 0 Then
EffaceFichier (CH & Fichier)
Else
EffaceRépertoire (CH & Fichier)
End If
End If
Cont = FindNextFile(hFile, WFD)
Loop
FindClose hFile
If Right$(CH, 1) = "" Then CH = Left$(CH, Len(CH) - 1)
N = RemoveDirectory(CH)
End Sub


On place cette procédure dasn un module comportant les éléments suivants
Option Explicit
Private Declare Function FindFirstFile Lib "kernel32" Alias "FindFirstFileA"
_
(ByVal lpFileName As String, lpFindFileData As WIN32_FIND_DATA) As
Long
Declare Function DeleteFile Lib "kernel32" Alias "DeleteFileA" ( _
ByVal lpFileName As String) As Long
Private Declare Function FindNextFile Lib "kernel32" Alias "FindNextFileA" _
(ByVal hFindFile As Long, lpFindFileData As WIN32_FIND_DATA) As
Long
Private Declare Function GetFileAttributes Lib "kernel32" Alias
"GetFileAttributesA" _
(ByVal lpFileName As String) As Long
Private Declare Function FindClose Lib "kernel32" (ByVal hFindFile As Long)
As Long
Private Declare Function RemoveDirectory Lib "kernel32" Alias
"RemoveDirectoryA" (ByVal lpPathName As String) As Long

Avec aussi la procédure
Public Sub EffaceFichier(Fichier As String)
DeleteFile (Fichier)
End Sub
Avatar
X
Kill "pathrépertoire*.*"
rmdir "pathrépertoire"


--
ECRIRE
http://irolog.free.fr/ecrire/index.htm

LOGICIELS
http://irolog.free.fr

SITE
http://irolog.free.fr/joe/index.htm

FAQ VB
http://faq.vb.free.fr

PRINCIPE D'UTILISATION DES NEWSGROUPS MICROSOFT
http://support.microsoft.com/directory/worldwide/fr/newsgroup/regles.htm
********************************************************



"Patrice Henrio" a écrit dans le message de
news: u%
J'ai utilisé le code que j'ai trouvé dans AllApi

Private Declare Function CreateDirectoryEx Lib "kernel32" Alias
"CreateDirectoryExA" (ByVal lpTemplateDirectory As String, ByVal
lpNewDirectory As String, lpSecurityAttributes As Any) As Long
Private Declare Function RemoveDirectory Lib "kernel32" Alias
"RemoveDirectoryA" (ByVal lpPathName As String) As Long
Private Sub Form_Load()
'KPD-Team 1999
'URL: http://www.allapi.net/
'E-Mail:
'Create a new directory
CreateDirectoryEx "C:Windows", "C:KPD-Team", ByVal 0&
'remove the directory
RemoveDirectory "C:KPD-Team"
End Sub

Cela marche bien pour créer un répertoire (même si je ne vois pas vraiment
à quoi sert le premier argument :
· lpTemplateDirectory
Points to a null-terminated string that specifies the path of the
directory to use as a template when creating the new directory.
Par contre le removeDirectory ne marche pas ?

Quelqu'un a-t'il une idée



Avatar
Patrice Henrio
J'aurai du chercher plus loin avant de perdre mon temps.

Y-a-t'il des cas où Kill fonctionnerait mal ?
(je pense à certaines versions de Windows ou à des noms de fichiers
exotiques avec des attributs particuliers)

"X" <.> a écrit dans le message de news:

Kill "pathrépertoire*.*"
rmdir "pathrépertoire"


--
ECRIRE
http://irolog.free.fr/ecrire/index.htm

LOGICIELS
http://irolog.free.fr

SITE
http://irolog.free.fr/joe/index.htm

FAQ VB
http://faq.vb.free.fr

PRINCIPE D'UTILISATION DES NEWSGROUPS MICROSOFT
http://support.microsoft.com/directory/worldwide/fr/newsgroup/regles.htm
********************************************************



"Patrice Henrio" a écrit dans le message de
news: u%
J'ai utilisé le code que j'ai trouvé dans AllApi

Private Declare Function CreateDirectoryEx Lib "kernel32" Alias
"CreateDirectoryExA" (ByVal lpTemplateDirectory As String, ByVal
lpNewDirectory As String, lpSecurityAttributes As Any) As Long
Private Declare Function RemoveDirectory Lib "kernel32" Alias
"RemoveDirectoryA" (ByVal lpPathName As String) As Long
Private Sub Form_Load()
'KPD-Team 1999
'URL: http://www.allapi.net/
'E-Mail:
'Create a new directory
CreateDirectoryEx "C:Windows", "C:KPD-Team", ByVal 0&
'remove the directory
RemoveDirectory "C:KPD-Team"
End Sub

Cela marche bien pour créer un répertoire (même si je ne vois pas
vraiment à quoi sert le premier argument :
· lpTemplateDirectory
Points to a null-terminated string that specifies the path of the
directory to use as a template when creating the new directory.
Par contre le removeDirectory ne marche pas ?

Quelqu'un a-t'il une idée







Avatar
X
Salut,

Je ne sais pas en fait, j'utilise kill *.* pour mes sauvegardes sur
disquettes, je n'ai jamais essayé avec autre chose que des fichiers
identifiés donc, mais je présume que les jokers devraient marcher pour tout
:o)
Mais sinon, beaucoup de commande Dos sont intéressantes et exploitables...

--

ECRIRE
http://irolog.free.fr/ecrire/index.htm

LOGICIELS
http://irolog.free.fr

SITE
http://irolog.free.fr/joe/index.htm

FAQ VB
http://faq.vb.free.fr

PRINCIPE D'UTILISATION DES NEWSGROUPS MICROSOFT
http://support.microsoft.com/directory/worldwide/fr/newsgroup/regles.htm
********************************************************



"Patrice Henrio" a écrit dans le message de
news:
J'aurai du chercher plus loin avant de perdre mon temps.

Y-a-t'il des cas où Kill fonctionnerait mal ?
(je pense à certaines versions de Windows ou à des noms de fichiers
exotiques avec des attributs particuliers)

"X" <.> a écrit dans le message de news:

Kill "pathrépertoire*.*"
rmdir "pathrépertoire"


--
ECRIRE
http://irolog.free.fr/ecrire/index.htm

LOGICIELS
http://irolog.free.fr

SITE
http://irolog.free.fr/joe/index.htm

FAQ VB
http://faq.vb.free.fr

PRINCIPE D'UTILISATION DES NEWSGROUPS MICROSOFT
http://support.microsoft.com/directory/worldwide/fr/newsgroup/regles.htm
********************************************************



"Patrice Henrio" a écrit dans le message de
news: u%
J'ai utilisé le code que j'ai trouvé dans AllApi

Private Declare Function CreateDirectoryEx Lib "kernel32" Alias
"CreateDirectoryExA" (ByVal lpTemplateDirectory As String, ByVal
lpNewDirectory As String, lpSecurityAttributes As Any) As Long
Private Declare Function RemoveDirectory Lib "kernel32" Alias
"RemoveDirectoryA" (ByVal lpPathName As String) As Long
Private Sub Form_Load()
'KPD-Team 1999
'URL: http://www.allapi.net/
'E-Mail:
'Create a new directory
CreateDirectoryEx "C:Windows", "C:KPD-Team", ByVal 0&
'remove the directory
RemoveDirectory "C:KPD-Team"
End Sub

Cela marche bien pour créer un répertoire (même si je ne vois pas
vraiment à quoi sert le premier argument :
· lpTemplateDirectory
Points to a null-terminated string that specifies the path of the
directory to use as a template when creating the new directory.
Par contre le removeDirectory ne marche pas ?

Quelqu'un a-t'il une idée











Avatar
Patrice Henrio
Je ne me souviens pas de kill comme commande dos, mais delete et del pour
les fichiers et removedir et rmd pour les dossiers.



"X" <.> a écrit dans le message de news:

Salut,

Je ne sais pas en fait, j'utilise kill *.* pour mes sauvegardes sur
disquettes, je n'ai jamais essayé avec autre chose que des fichiers
identifiés donc, mais je présume que les jokers devraient marcher pour
tout :o)
Mais sinon, beaucoup de commande Dos sont intéressantes et exploitables...

--

ECRIRE
http://irolog.free.fr/ecrire/index.htm

LOGICIELS
http://irolog.free.fr

SITE
http://irolog.free.fr/joe/index.htm

FAQ VB
http://faq.vb.free.fr

PRINCIPE D'UTILISATION DES NEWSGROUPS MICROSOFT
http://support.microsoft.com/directory/worldwide/fr/newsgroup/regles.htm
********************************************************



"Patrice Henrio" a écrit dans le message de
news:
J'aurai du chercher plus loin avant de perdre mon temps.

Y-a-t'il des cas où Kill fonctionnerait mal ?
(je pense à certaines versions de Windows ou à des noms de fichiers
exotiques avec des attributs particuliers)

"X" <.> a écrit dans le message de news:

Kill "pathrépertoire*.*"
rmdir "pathrépertoire"


--
ECRIRE
http://irolog.free.fr/ecrire/index.htm

LOGICIELS
http://irolog.free.fr

SITE
http://irolog.free.fr/joe/index.htm

FAQ VB
http://faq.vb.free.fr

PRINCIPE D'UTILISATION DES NEWSGROUPS MICROSOFT
http://support.microsoft.com/directory/worldwide/fr/newsgroup/regles.htm
********************************************************



"Patrice Henrio" a écrit dans le message de
news: u%
J'ai utilisé le code que j'ai trouvé dans AllApi

Private Declare Function CreateDirectoryEx Lib "kernel32" Alias
"CreateDirectoryExA" (ByVal lpTemplateDirectory As String, ByVal
lpNewDirectory As String, lpSecurityAttributes As Any) As Long
Private Declare Function RemoveDirectory Lib "kernel32" Alias
"RemoveDirectoryA" (ByVal lpPathName As String) As Long
Private Sub Form_Load()
'KPD-Team 1999
'URL: http://www.allapi.net/
'E-Mail:
'Create a new directory
CreateDirectoryEx "C:Windows", "C:KPD-Team", ByVal 0&
'remove the directory
RemoveDirectory "C:KPD-Team"
End Sub

Cela marche bien pour créer un répertoire (même si je ne vois pas
vraiment à quoi sert le premier argument :
· lpTemplateDirectory
Points to a null-terminated string that specifies the path of the
directory to use as a template when creating the new directory.
Par contre le removeDirectory ne marche pas ?

Quelqu'un a-t'il une idée















Avatar
X
Affirmatif, del, delete, deltree (erase?)... Je ne sais pas d'où vient le
"kill" (killer", lol :o)

--
ECRIRE
http://irolog.free.fr/ecrire/index.htm

LOGICIELS
http://irolog.free.fr

SITE
http://irolog.free.fr/joe/index.htm

FAQ VB
http://faq.vb.free.fr

PRINCIPE D'UTILISATION DES NEWSGROUPS MICROSOFT
http://support.microsoft.com/directory/worldwide/fr/newsgroup/regles.htm
********************************************************



"Patrice Henrio" a écrit dans le message de
news:
Je ne me souviens pas de kill comme commande dos, mais delete et del pour
les fichiers et removedir et rmd pour les dossiers.



"X" <.> a écrit dans le message de news:

Salut,

Je ne sais pas en fait, j'utilise kill *.* pour mes sauvegardes sur
disquettes, je n'ai jamais essayé avec autre chose que des fichiers
identifiés donc, mais je présume que les jokers devraient marcher pour
tout :o)
Mais sinon, beaucoup de commande Dos sont intéressantes et
exploitables...

--

ECRIRE
http://irolog.free.fr/ecrire/index.htm

LOGICIELS
http://irolog.free.fr

SITE
http://irolog.free.fr/joe/index.htm

FAQ VB
http://faq.vb.free.fr

PRINCIPE D'UTILISATION DES NEWSGROUPS MICROSOFT
http://support.microsoft.com/directory/worldwide/fr/newsgroup/regles.htm
********************************************************



"Patrice Henrio" a écrit dans le message de
news:
J'aurai du chercher plus loin avant de perdre mon temps.

Y-a-t'il des cas où Kill fonctionnerait mal ?
(je pense à certaines versions de Windows ou à des noms de fichiers
exotiques avec des attributs particuliers)

"X" <.> a écrit dans le message de news:

Kill "pathrépertoire*.*"
rmdir "pathrépertoire"


--
ECRIRE
http://irolog.free.fr/ecrire/index.htm

LOGICIELS
http://irolog.free.fr

SITE
http://irolog.free.fr/joe/index.htm

FAQ VB
http://faq.vb.free.fr

PRINCIPE D'UTILISATION DES NEWSGROUPS MICROSOFT
http://support.microsoft.com/directory/worldwide/fr/newsgroup/regles.htm
********************************************************



"Patrice Henrio" a écrit dans le message
de news: u%
J'ai utilisé le code que j'ai trouvé dans AllApi

Private Declare Function CreateDirectoryEx Lib "kernel32" Alias
"CreateDirectoryExA" (ByVal lpTemplateDirectory As String, ByVal
lpNewDirectory As String, lpSecurityAttributes As Any) As Long
Private Declare Function RemoveDirectory Lib "kernel32" Alias
"RemoveDirectoryA" (ByVal lpPathName As String) As Long
Private Sub Form_Load()
'KPD-Team 1999
'URL: http://www.allapi.net/
'E-Mail:
'Create a new directory
CreateDirectoryEx "C:Windows", "C:KPD-Team", ByVal 0&
'remove the directory
RemoveDirectory "C:KPD-Team"
End Sub

Cela marche bien pour créer un répertoire (même si je ne vois pas
vraiment à quoi sert le premier argument :
· lpTemplateDirectory
Points to a null-terminated string that specifies the path of the
directory to use as a template when creating the new directory.
Par contre le removeDirectory ne marche pas ?

Quelqu'un a-t'il une idée