En utilisant VB6Vous remplacez un problème de nom de fichier?
Dans un dossier, je suis d'avoir un nombre n de fichiers texte, les noms de fichiers sont comme abc.mis-txt, def.fin @ txt, donc je veux renommer les noms de fichiers comme abcmis.txt, deffin.txt. J'ai utilisé une fonction pour renommer.
code
Dim filename3 As String
filename3 = Dir$(txtSourceDatabaseFile & "\*.txt", vbDirectory)
Do While filename3 <> ""
« Fonction pour renommer
Dim strInput As String
Dim stroutput As String
Dim strChar As String
Dim intChar As Integer
Dim intLoop As Integer
strInput = filename3
For intLoop = 1 To Len(strInput)
strChar = Mid$(strInput, intLoop, 1)
intChar = Asc(strChar)
If ((intChar >= 48) And (intChar <= 57)) Or _
((intChar >= 65) And (intChar <= 90)) Or _
((intChar >= 97) And (intChar <= 122)) Or _
(intChar = 95) Then
stroutput = stroutput & strChar
End If
Next
Name txtSourceDatabaseFile & "\" & filename3 As txtSourceDatabaseFile & "\" & stroutput & ".txt"
filename3 = Dir$
Loop
Au-dessus de codage fonctionne, le problème est me sers tout conditon, il renomme tous les fichiers txt, il donne un nom J'aime
Par exemple. Il ajoute aussi un nom de fichier précédent, car j'obtiens un nom de fichier dans while loop lui-même.
Comment modifier mon code.