Announcement

Collapse
No announcement yet.

Copy And Rename folder in vb2008

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Copy And Rename folder in vb2008

    I have googled this for a while, but still not found the code i wanted. As i'm not a guru in scripting it's kina hard for me. Maby you guys here can help. Here is the problem:

    I have a folder, this folder is always at the same place with the same name.
    I want to copy this folder to another location, wich will always be the same location. But i want to rename the folder when i copy it. And the renaming should come from a textbox in my vbscript. So it would be something like this:

    copyfolder ("c:\folderpath\folder", "c:\otherfolderpath\"textbox1")

    where "folder" is the folder i want to copy, and "textbox1" is the box where i want to write the name the folder should have when it gets copied.

  • #2
    Re: Copy And Rename folder in vb2008

    Is this running from a script or a web form?
    Tom Jones
    MCT, MCSE (2000:Security & 2003), MCSA:Security & Messaging, MCDBA, MCDST, MCITP(EA, EMA, SA, EDA, ES, CS), MCTS, MCP, Sec+
    PhD, MSc, FIAP, MIITT
    IT Trainer / Consultant
    Ossian Ltd
    Scotland

    ** Remember to give credit where credit is due and leave reputation points where appropriate **

    Comment


    • #3
      Re: Copy And Rename folder in vb2008

      I have created a windows application in vb2008, and i have made the button, and the textbox. So all i need now is the code to write inside the "button" so the copy will happen.

      Did that make any sence? =)

      Comment


      • #4
        Re: Copy And Rename folder in vb2008

        OK -- so full visual basic, not VBScript as the first post suggested

        You would probably want something like:

        strTarget = "c:\otherfolderpath\" & textbox1.text
        copyfolder ("c:\folderpath\folder", strTarget)

        The first line makes a string by combining the fixed and variable parts of the path (stored in the text attribute of textbox1
        The second line passes this string to the copyfolder function (note I do not know if this is the correct syntax for copyfolder)
        Last edited by Ossian; 8th July 2009, 12:03.
        Tom Jones
        MCT, MCSE (2000:Security & 2003), MCSA:Security & Messaging, MCDBA, MCDST, MCITP(EA, EMA, SA, EDA, ES, CS), MCTS, MCP, Sec+
        PhD, MSc, FIAP, MIITT
        IT Trainer / Consultant
        Ossian Ltd
        Scotland

        ** Remember to give credit where credit is due and leave reputation points where appropriate **

        Comment


        • #5
          Re: Copy And Rename folder in vb2008

          Yes. Sorry for not been clear enough in my first post.

          I put in your code, and it came out with 2 errors

          Name 'strTarget' is not declared
          Name 'copyfoler' is not declared

          I have made this "program" before. Put i managed to delete the code. I only have the program. The program works fine as it is, but i was going to make some more out of it.

          It already could do the following things:
          Copy the folder and rename it to the tekst in textboks1
          Modify the .ini file in the new folder
          Make a service of the exe file in the new folder, and create 2 registry keys
          Start the service.

          But I'm having trouble with the first (and probably) easy one. So i tought i would focus to get this one right first.

          Comment


          • #6
            Re: Copy And Rename folder in vb2008

            Dim strTarget as String
            (at the top of your code) will resolve the first error
            The second looks like a typo or maybe a copyfolder function needs to be written
            Tom Jones
            MCT, MCSE (2000:Security & 2003), MCSA:Security & Messaging, MCDBA, MCDST, MCITP(EA, EMA, SA, EDA, ES, CS), MCTS, MCP, Sec+
            PhD, MSc, FIAP, MIITT
            IT Trainer / Consultant
            Ossian Ltd
            Scotland

            ** Remember to give credit where credit is due and leave reputation points where appropriate **

            Comment

            Working...
            X