dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: Transfert folders/Files to another folder

  1. #1
    Join Date
    Feb 2019
    Posts
    3

    Transfert folders/Files to another folder

    Good morning to the Community.

    I would like to transfer files to a new directory.

    In one key "1 - ABC"(fromPath - key: NomNameMatrk) and in the other "ABC - 1" (toPath - key: NomName)

    The "ABC - 1" and subsequent files are empty while the "1 - ABC" files contain sub-files.


    In the following code I already tried move and copy File. But puts me either an error message 76 or 53

    Code:
    Private Sub Renommer_Fichiers()
    Dim fso As Object
        Dim fromPath As String, toPath As String, strPath As String, strPathto As String, strSql As String
        Dim dbs As DAO.Database
        Dim rst As DAO.Recordset
     
        toPath = "P:\Dossier1\Dossier2\Dossier3\"  '<< Change
        fromPath = "K:\Classeur1\Classeur2\Classeur3\Classeur4\Classeur5\Classeur6\"    '<< Change
        fileExt = ".pdf"  '< Change
     
        Set dbs = CurrentDb
        Set fso = CreateObject("Scripting.FileSystemObject")
     
        strSql = "SELECT Matr, NomName, NomNameMatr, NomNameMatrk,Languagecode FROM DEC "
        'WHERE CDbl(Nz([Numero],0))>1"
     
        'Debug.Print strSql
        Set rst = dbs.OpenRecordset(strSql, dbOpenSnapshot, dbFailOnError)
     
                While Not rst.EOF
     
                strPath = fromPath & rst!NomNameMatrK
                strPathto = toPath & rst!NomName
                      ' If Len(Dir(strPath, vbDirectory)) = 0 Then
                      '  MkDir strPathto
                      '  Else
     
                      If Not Len(Dir(strPath, vbDirectory)) Then
                      fso.MoveFolder strPath, strPathto
     
                     '   End If
                 End If
     
                rst.MoveNext
                Wend
     
        rst.Close
        Set fso = Nothing
        Set rst = Nothing
        Set dbs = Nothing
    End Sub

  2. #2
    Join Date
    Jun 1999
    Location
    Eastern Florida
    Posts
    3,856

    Re: Transfert folders/Files to another folder

    What language is that written in? This is a java programming forum.
    Norm

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)