Copying Files in VB6

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Ali Rizwan
    Banned
    Contributor
    • Aug 2007
    • 931

    Copying Files in VB6

    Hello everybody.
    I have a problem in fso.copyfiles in vb6.0.Please help me in copying files and how to rename them.
    Thanks
  • pureenhanoi
    New Member
    • Mar 2007
    • 175

    #2
    Originally posted by Ali Rizwan
    Hello everybody.
    I have a problem in fso.copyfiles in vb6.0.Please help me in copying files and how to rename them.
    Thanks
    [CODE=VB]
    Name "d:\file1.t xt" As "c\file2.tx t"
    [/CODE]
    Last edited by pureenhanoi; Aug 17 '07, 02:38 AM. Reason: change CODE tag

    Comment

    • fplesco
      New Member
      • Jul 2007
      • 82

      #3
      Originally posted by Ali Rizwan
      Hello everybody.
      I have a problem in fso.copyfiles in vb6.0.Please help me in copying files and how to rename them.
      Thanks
      Hey -

      You can also try it.

      This code will copy a file, and of the same time, will rename a file.

      Code:
      FileCopy "C:\<SourceFolder>SourceFile.txt","C:<DestinationFolder>\DestinationFile.txt"

      Comment

      • Killer42
        Recognized Expert Expert
        • Oct 2006
        • 8429

        #4
        Originally posted by Ali Rizwan
        I have a problem in fso.copyfiles in vb6.0.Please help me in copying files and how to rename them.
        What sort of problem?

        Comment

        • Ali Rizwan
          Banned
          Contributor
          • Aug 2007
          • 931

          #5
          Originally posted by Killer42
          What sort of problem?
          Thanks for reply
          i am using this code
          Set f = fso.CopyFile("D :\Ali.txt", "D:\Ali\Ali.txt ")
          and the error is
          Expected Function or Variable

          Comment

          • Ali Rizwan
            Banned
            Contributor
            • Aug 2007
            • 931

            #6
            Originally posted by fplesco
            Hey -

            You can also try it.

            This code will copy a file, and of the same time, will rename a file.

            Code:
            FileCopy "C:\<SourceFolder>SourceFile.txt","C:<DestinationFolder>\DestinationFile.txt"
            Thanks for reply
            I use and an error of syntax error.
            Some times i got an error of =expected

            Comment

            • Ali Rizwan
              Banned
              Contributor
              • Aug 2007
              • 931

              #7
              Originally posted by pureenhanoi
              [CODE=VB]
              Name "d:\file1.t xt" As "c\file2.tx t"
              [/CODE]
              Thanks for reply.
              Can you explain it to me. plzzzz

              Comment

              • Killer42
                Recognized Expert Expert
                • Oct 2006
                • 8429

                #8
                Originally posted by Ali Rizwan
                Set f = fso.CopyFile("D :\Ali.txt", "D:\Ali\Ali.txt ")
                and the error is
                Expected Function or Variable
                That's because you're trying to assign something to a variable (f). Don't do that, just execute the CopyFile. Leave off the "Set f =".

                Comment

                • Killer42
                  Recognized Expert Expert
                  • Oct 2006
                  • 8429

                  #9
                  Originally posted by Ali Rizwan
                  I use and an error of syntax error.
                  Some times i got an error of =expected
                  That probably means you're putting parentheses around the parameters. If you code it exactly as shown, I think it will work.

                  Comment

                  • Killer42
                    Recognized Expert Expert
                    • Oct 2006
                    • 8429

                    #10
                    Originally posted by Ali Rizwan
                    Can you explain it to me. plzzzz
                    What is there to explain? That's the whole of it. The Name x As y command renames a file (and if necessary, moves it to a different folder). Look it up in your VB doco.

                    It's important to note, though, that this doesn't copy - it moves. Big difference!

                    Comment

                    • Ali Rizwan
                      Banned
                      Contributor
                      • Aug 2007
                      • 931

                      #11
                      Originally posted by Killer42
                      That probably means you're putting parentheses around the parameters. If you code it exactly as shown, I think it will work.

                      OK
                      I try it and it works properly.
                      I am thakfull to you for this.
                      Now only one question more.
                      When using statement
                      copyfile is there no need of fso or yes.

                      Thanks a lot again

                      Comment

                      • Killer42
                        Recognized Expert Expert
                        • Oct 2006
                        • 8429

                        #12
                        Originally posted by Ali Rizwan
                        I try it and it works properly.
                        I am thakfull to you for this.
                        Now only one question more.
                        When using statement
                        copyfile is there no need of fso or yes.
                        Glad to see you got it working. :)

                        As for the fso question, I don't know. My guess would be that you do need the fso reference, as FileCopy is a method of the fso. However, my general advice is - "if in doubt, try it out".

                        Comment

                        Working...