A dire la verità ho un problema con un programma che deve copiare dei file da una directory di origine
File1.Path = Dir1.Path ed incollarlo in una cartella
.Destination = filTemp.Path
Dopo aver fatto questa operazione il file deve essere rinominato con delle sintassi definite . Il problema che riscontro è che dopo essere stato incollato e rinominato il file in questione si cancella dalla directory di origine e questo non voglio che accade. Vi posto tutte le istruzioni del programma se necessario. Comunque io ho pensato che il problema potesse dipendere da :
Private Sub cmdCopia_Click()
Dim intLoop As Integer
Dim strFiles As String
With File1
For intLoop = 0 To .ListCount - 1
If .Selected(intLoop) Then strFiles = strFiles & _
LastBSlash(File1.Path) & .List(intLoop) & vbNullChar
Next intLoop
If Len(strFiles) > 0 Then
strFiles = strFiles & vbNullChar
With fbiShellOperation
.Confirm = True
.AllowUndo = False
.Source = strFiles
.Destination = filTemp.Path
Call .Esegui(FO_COPY)
cmdAggiorna_Click
End With
File1.Refresh
End If
End With
End Sub
Private Sub Rename_Click()
On Error GoTo Errore:
Dim k, h, l, Selected As Integer
Dim files1, files2 As String
Rename.Enabled = False
For j = 0 To filTemp.ListCount - 1
If filTemp.Selected(j) Then Selected = Selected + 1
Next j
For j = 0 To filTemp.ListCount - 1
If filTemp.Selected(j) Then
DoEvents
k = k + 1
files1 = filTemp.List(j)
h = InStr(1, files1, ".", vbTextCompare)
If h = 0 Then h = Len(files1) + 1
Select Case Combo1.ListIndex
Case 0:
files2 = UCase(Left(files1, 1)) & LCase(Right(files1, Len(files1) - 1))
Case 1:
files2 = UCase(Left(files1, 1)) & LCase(Mid(files1, 2, h - 1)) & UCase(Right(files1, Len(files1) - h))
Case 2:
files2 = LCase(Left(files1, 1)) & UCase(Right(files1, Len(files1) - 1))
Case 3:
files2 = LCase(Left(files1, 1)) & UCase(Mid(files1, 2, h - 1)) & LCase(Right(files1, Len(files1) - h))
Case 4:
files2 = LCase(files1)
Case 5:
files2 = UCase(files1)
Case 6:
files2 = Text1.Text & Format(l, " "
& "." & Right(files1, Len(files1) - h)
l = l + 1
Case 7:
files2 = Text1.Text & Format(l, "000"
& "." & Right(files1, Len(files1) - h)
l = l + 1
Case 8:
files2 = Left(files1, h - 1) & Text1.Text & "." & Right(files1, Len(files1) - h)
Case 9:
files2 = Text1.Text & Left(files1, h - 1) & "." & Right(files1, Len(files1) - h)
Case 10:
files2 = Left(files1, h - 1) & "." & Text1.Text
End Select
Name Dir1.Path & "\" & files1 As filTemp.Path & "\" & files2
'we can utilise also: ShellRenameOne filTemp.Path & "\" & files1, Dir1.Path & "\" & files2
Form2.ProgressBar1.Value = 100 * (k / Selected)
End If
Next j
filTemp.Refresh
Unload Form2
StatusBar1.SimpleText = "0 selected files"
Exit Sub
Errore:
If Err = 58 Then
MsgBox "Filename already exists!"
Resume Next
End If
End Sub
Nota bene le righe contrassegnate con le faccine .