Quantcast
Channel: Visual Basic Tips and Tricks
Viewing all articles
Browse latest Browse all 2212

Copia file tra cartelle

$
0
0

Buonasera a tutti,

piccolo problema nello spostare file tra cartelle.

Ho tre cartelle (A, B e C) e tre fasi di lavorazione.

Nella prima fase dalla cartella A, di partenza, sposto 4 file txt nella cartella B e fin qui tutto OK

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click

        Dim Sorgente As New FolderBrowserDialog
        Dim elenco() As String
        Dim Destinazione As String
        Dim Nomefile As String
        Dim elementi() As String

        Sorgente.SelectedPath = "path"


        Destinazione = ("path")
    
        If Sorgente.ShowDialog = Windows.Forms.DialogResult.OK Then
          
            elenco = Directory.GetFiles(Sorgente.SelectedPath)
          
            For Each x As String In elenco
             
                elementi = Split(x, "\")
                Nomefile = elementi(elementi.Length - 1)

                If Nomefile = "desktop.ini" = False Then
                    Try
                        File.Move(Sorgente.SelectedPath & "\"& Nomefile, Destinazione & "\"& Nomefile)
                    Catch ex As Exception

                    End Try

                End If

                           Next

            MsgBox("Files txt copiati")

        End If
    End Sub

Nella seconda fase dalla cartella B, dopo aver modificato i dati nei 4 file txt, li sposto in C e fin qui tutto OK.

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click

        Dim Sorgente1 As New FolderBrowserDialog
        Dim elenco1() As String
        Dim Destinazione1 As String
        Dim Nomefile1 As String
        Dim elementi1() As String


        Sorgente1.SelectedPath() = "path"

        Destinazione1 = ("path")
     
        If Sorgente1.ShowDialog = Windows.Forms.DialogResult.OK Then
          
            elenco1 = Directory.GetFiles(Sorgente1.SelectedPath)
                       For Each x As String In elenco1
            
                elementi1 = Split(x, "\")
                Nomefile1 = elementi1(elementi1.Length - 1)

                If Nomefile1 = "desktop.ini" = False Then
                    File.Move(Sorgente1.SelectedPath & "\"& Nomefile1, Destinazione1 & "\"& Nomefile1)
                End If
               
                     Next
            MsgBox("Copia file in DATI IN completato")
        End If



    End Sub

Nella terza fase, quando da C cerco di riportarli nella cartella A con le stesse istruzioni che uso per le altre due fasi, non sposta niente.

 Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
        Dim Sorgente3 As New FolderBrowserDialog
        Dim elenco3() As String
        Dim Destinazione3 As String
        Dim Nomefile3 As String
        Dim elementi3() As String


        Sorgente3.SelectedPath() = "path"

        Destinazione3 = ("path")
     
        If Sorgente3.ShowDialog = Windows.Forms.DialogResult.OK Then
          
            elenco3 = Directory.GetFiles(Sorgente3.SelectedPath)
        
            For Each x As String In elenco3
                             elementi3 = Split(x, "\")
                Nomefile3 = elementi3(elementi3.Length - 1)

                If Nomefile3 = "desktop.ini" = False Then
                                     'Try
                    File.Move(Sorgente3.SelectedPath & "\"& Nomefile3, Destinazione3 & "\"& Nomefile3)
                
                End If
                         Next

            MsgBox("Copia file txt in OCR completato")
        End If
    End Sub

Domanda. Devo rendere ridisponibile la cartella A dopo la prima fase ?

 

Grazie e buona serata a tutti


Viewing all articles
Browse latest Browse all 2212

Trending Articles


Vimeo 10.7.1 by Vimeo.com, Inc.


UPDATE SC IDOL: TWO BECOME ONE


KASAMBAHAY BILL IN THE HOUSE


Girasoles para colorear


Presence Quotes – Positive Quotes


EASY COME, EASY GO


Love with Heart Breaking Quotes


Re:Mutton Pies (lleechef)


Ka longiing longsem kaba skhem bad kaba khlain ka pynlong kein ia ka...


Vimeo 10.7.0 by Vimeo.com, Inc.


FORECLOSURE OF REAL ESTATE MORTGAGE


FORTUITOUS EVENT


Pokemon para colorear


Sapos para colorear


Smile Quotes


Letting Go Quotes


Love Song lyrics that marks your Heart


RE: Mutton Pies (frankie241)


Hato lada ym dei namar ka jingpyrshah jong U JJM Nichols Roy (Bah Joy) ngin...


Long Distance Relationship Tagalog Love Quotes