CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9
  1. #1
    Join Date
    Mar 2011
    Posts
    6

    overwriting a file

    Hi, iv made a updater which seems to work until it gets to the part where i have to download the new version of the program

    could someone please show me how i can replace an existing file, then close the program and automatically open the file which has just been downloaded?


    any help would be great

    Ben

  2. #2
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: overwriting a file

    Call a SECOND program, to close the first, and apply the update. It can check each time you start or exit the program
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  3. #3
    Join Date
    Mar 2011
    Posts
    6

    Re: overwriting a file

    ooo ok thanks

    is there no way to do within one program?


    also how can i replace the existing file? when the updater runs it checks for the update then if needed downloads it. however if the file already exists in the folder and i get an error saying "could not complete operation since a file already exists in this path"

  4. #4
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: overwriting a file

    After you download it, you can delete the old one, as long as you're sure the new one will work. Maybe even MOVE it out of the program path, into a backup folder telling the date/version, as the filename will be the same for all files.
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  5. #5
    Join Date
    Aug 2003
    Location
    Sydney, Australia
    Posts
    1,900

    Re: overwriting a file

    Did you know that you are able to rename a program file either manually, or by program command, even though it is running

    eg, MyProg.exe can be renamed to MyProg.old while it is running

    Code:
    Name "C:\MyProg.exe " As "C:\MyProg.old"
    This will then allow you to copy a new version of MyProg.exe which will be run next time the user starts up the program

  6. #6
    Join Date
    Mar 2011
    Posts
    6

    Re: overwriting a file

    all sorted now thanks

  7. #7
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,283

    Re: overwriting a file

    Mark your thread resolved please

  8. #8
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: overwriting a file

    Quote Originally Posted by George1111 View Post
    Did you know that you are able to rename a program file either manually, or by program command, even though it is running

    eg, MyProg.exe can be renamed to MyProg.old while it is running

    Code:
    Name "C:\MyProg.exe " As "C:\MyProg.old"
    This will then allow you to copy a new version of MyProg.exe which will be run next time the user starts up the program
    Really? I did not know that. I assumed the program would be locked against rename as well. I'll have to give it a try, could have it's uses.
    Always use [code][/code] tags when posting code.

  9. #9
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: overwriting a file

    Win7 loads programs into memory
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured