Comment créer un Dossier sur un graveur de CD, via la commande MkDir ?
j'obtiens une erreur '76' chemin d'accès introuvable.
Sachant que cela fonctionne pour une disquette.
Salutations.
Cette action est irreversible, confirmez la suppression du commentaire ?
Signaler le commentaire
Veuillez sélectionner un problème
Nudité
Violence
Harcèlement
Fraude
Vente illégale
Discours haineux
Terrorisme
Autre
Picalausa François
Hello,
Cette erreur peut se produire si tu essaye de créer deux niveaux de dossiers d'un coup (exemple, mkdir "c:tototata" alors que c: ne contient pas toto). Il faudra alors décomposer la séquence de création (mkdir "c:toto" suivit de mkdir "c:tototata")
Voici un exemple: 'S'assure de l'existence du chemin Public Function PreparePath(strPath As String) As Boolean Dim strExistingPath As String, PathDiff As String
PreparePath = strPath Like "[A-Za-z]:*"
If PreparePath Then strExistingPath = strPath
While FolderExists(strExistingPath) = False 'Remonte dans la hiérarchie strExistingPath = Left$(strExistingPath, InStrRev(strExistingPath, "") - 1) Wend
'Teste l'existence d'un fichier portant le nom que l'on souhaite PreparePath = FileExists(EndPath(strExistingPath) & GetNextChunk(PathDiff, "")) = False If PreparePath Then While LenB(PathDiff) 'Retrouve le prochain morceau à créer strExistingPath = EndPath(strExistingPath) & GetNextChunk(PathDiff, "", True)
'Crée ce morceau de path MkDir strExistingPath Wend Else Err.Raise 75, "Impossible de créer le dossier demandé : un fichier portant ce nom existe déjà!" End If Else Err.Raise 75, "Le nom de dossier doit être complètement qualifié!" End If End Function
Public Function EndPath(FilePath As String) As String EndPath = Trim$(FilePath) If Right$(EndPath, 1) <> "" Then EndPath = EndPath & "" End Function
Public Function FileExists(FilePath As String) As Boolean On Error Resume Next FileExists = (GetAttr(FilePath) And vbDirectory) = 0 End Function
'Retrouve la partie précédent Delimiter dans Text 'Si DoStrip, retire cette partie de Text Public Function GetNextChunk(Text As String, Delimiter As String, Optional DoStrip As Boolean = False) As String Dim ChunkEnd As Long ChunkEnd = InStr(Text, Delimiter)
If ChunkEnd Then GetNextChunk = Left$(Text, ChunkEnd - 1) Else GetNextChunk = Text ChunkEnd = Len(Text) End If
If DoStrip Then Text = Mid$(Text, ChunkEnd + 1) End If End Function
'Le dossier existe-t-il? Public Function FolderExists(FilePath As String) As Boolean On Error Resume Next FolderExists = (GetAttr(FilePath) And vbDirectory) = vbDirectory End Function
'Exemple d'utilisation Private Sub Form_Load()
On Error GoTo err_handler If PreparePath("C:Documents and SettingsFrançoisMes documentsProgrammationTotoTata") Then MsgBox "Succès!" End If
err_handler: End Sub
-- Picalausa François
"Gérard BONNAMAIN" <Gérard a écrit dans le message de news:
Bonjour,
Comment créer un Dossier sur un graveur de CD, via la commande MkDir ? j'obtiens une erreur '76' chemin d'accès introuvable. Sachant que cela fonctionne pour une disquette. Salutations.
Hello,
Cette erreur peut se produire si tu essaye de créer deux niveaux de dossiers
d'un coup (exemple, mkdir "c:tototata" alors que c: ne contient pas
toto).
Il faudra alors décomposer la séquence de création (mkdir "c:toto" suivit
de mkdir "c:tototata")
Voici un exemple:
'S'assure de l'existence du chemin
Public Function PreparePath(strPath As String) As Boolean
Dim strExistingPath As String, PathDiff As String
PreparePath = strPath Like "[A-Za-z]:*"
If PreparePath Then
strExistingPath = strPath
While FolderExists(strExistingPath) = False
'Remonte dans la hiérarchie
strExistingPath = Left$(strExistingPath,
InStrRev(strExistingPath, "") - 1)
Wend
'Teste l'existence d'un fichier portant le nom que l'on souhaite
PreparePath = FileExists(EndPath(strExistingPath) &
GetNextChunk(PathDiff, "")) = False
If PreparePath Then
While LenB(PathDiff)
'Retrouve le prochain morceau à créer
strExistingPath = EndPath(strExistingPath) &
GetNextChunk(PathDiff, "", True)
'Crée ce morceau de path
MkDir strExistingPath
Wend
Else
Err.Raise 75, "Impossible de créer le dossier demandé : un
fichier portant ce nom existe déjà!"
End If
Else
Err.Raise 75, "Le nom de dossier doit être complètement qualifié!"
End If
End Function
Public Function EndPath(FilePath As String) As String
EndPath = Trim$(FilePath)
If Right$(EndPath, 1) <> "" Then EndPath = EndPath & ""
End Function
Public Function FileExists(FilePath As String) As Boolean
On Error Resume Next
FileExists = (GetAttr(FilePath) And vbDirectory) = 0
End Function
'Retrouve la partie précédent Delimiter dans Text
'Si DoStrip, retire cette partie de Text
Public Function GetNextChunk(Text As String, Delimiter As String, Optional
DoStrip As Boolean = False) As String
Dim ChunkEnd As Long
ChunkEnd = InStr(Text, Delimiter)
If ChunkEnd Then
GetNextChunk = Left$(Text, ChunkEnd - 1)
Else
GetNextChunk = Text
ChunkEnd = Len(Text)
End If
If DoStrip Then
Text = Mid$(Text, ChunkEnd + 1)
End If
End Function
'Le dossier existe-t-il?
Public Function FolderExists(FilePath As String) As Boolean
On Error Resume Next
FolderExists = (GetAttr(FilePath) And vbDirectory) = vbDirectory
End Function
'Exemple d'utilisation
Private Sub Form_Load()
On Error GoTo err_handler
If PreparePath("C:Documents and SettingsFrançoisMes
documentsProgrammationTotoTata") Then
MsgBox "Succès!"
End If
err_handler:
End Sub
--
Picalausa François
"Gérard BONNAMAIN" <Gérard BONNAMAIN@discussions.microsoft.com> a écrit dans
le message de news: 35593078-7E43-4AB5-816A-1E42C7C8E0B0@microsoft.com...
Bonjour,
Comment créer un Dossier sur un graveur de CD, via la commande MkDir ?
j'obtiens une erreur '76' chemin d'accès introuvable.
Sachant que cela fonctionne pour une disquette.
Salutations.
Cette erreur peut se produire si tu essaye de créer deux niveaux de dossiers d'un coup (exemple, mkdir "c:tototata" alors que c: ne contient pas toto). Il faudra alors décomposer la séquence de création (mkdir "c:toto" suivit de mkdir "c:tototata")
Voici un exemple: 'S'assure de l'existence du chemin Public Function PreparePath(strPath As String) As Boolean Dim strExistingPath As String, PathDiff As String
PreparePath = strPath Like "[A-Za-z]:*"
If PreparePath Then strExistingPath = strPath
While FolderExists(strExistingPath) = False 'Remonte dans la hiérarchie strExistingPath = Left$(strExistingPath, InStrRev(strExistingPath, "") - 1) Wend
'Teste l'existence d'un fichier portant le nom que l'on souhaite PreparePath = FileExists(EndPath(strExistingPath) & GetNextChunk(PathDiff, "")) = False If PreparePath Then While LenB(PathDiff) 'Retrouve le prochain morceau à créer strExistingPath = EndPath(strExistingPath) & GetNextChunk(PathDiff, "", True)
'Crée ce morceau de path MkDir strExistingPath Wend Else Err.Raise 75, "Impossible de créer le dossier demandé : un fichier portant ce nom existe déjà!" End If Else Err.Raise 75, "Le nom de dossier doit être complètement qualifié!" End If End Function
Public Function EndPath(FilePath As String) As String EndPath = Trim$(FilePath) If Right$(EndPath, 1) <> "" Then EndPath = EndPath & "" End Function
Public Function FileExists(FilePath As String) As Boolean On Error Resume Next FileExists = (GetAttr(FilePath) And vbDirectory) = 0 End Function
'Retrouve la partie précédent Delimiter dans Text 'Si DoStrip, retire cette partie de Text Public Function GetNextChunk(Text As String, Delimiter As String, Optional DoStrip As Boolean = False) As String Dim ChunkEnd As Long ChunkEnd = InStr(Text, Delimiter)
If ChunkEnd Then GetNextChunk = Left$(Text, ChunkEnd - 1) Else GetNextChunk = Text ChunkEnd = Len(Text) End If
If DoStrip Then Text = Mid$(Text, ChunkEnd + 1) End If End Function
'Le dossier existe-t-il? Public Function FolderExists(FilePath As String) As Boolean On Error Resume Next FolderExists = (GetAttr(FilePath) And vbDirectory) = vbDirectory End Function
'Exemple d'utilisation Private Sub Form_Load()
On Error GoTo err_handler If PreparePath("C:Documents and SettingsFrançoisMes documentsProgrammationTotoTata") Then MsgBox "Succès!" End If
err_handler: End Sub
-- Picalausa François
"Gérard BONNAMAIN" <Gérard a écrit dans le message de news:
Bonjour,
Comment créer un Dossier sur un graveur de CD, via la commande MkDir ? j'obtiens une erreur '76' chemin d'accès introuvable. Sachant que cela fonctionne pour une disquette. Salutations.