Results 1 to 8 of 8

Thread: how does this work

  1. #1

    Thread Starter
    Fanatic Member dark_shadow's Avatar
    Join Date
    Feb 2005
    Location
    Igloo
    Posts
    900

    how does this work

    hey guys i was expermenting a while ago to see if it were even possable to make a file replicate itself at run time (mainly because it doesnt seem possible) and i found a method on how to do it in vb using the following code

    VB Code:
    1. FileCopy App.Path + "\" + App.Title + ".exe", "C:\myapp.exe"

    but i cant for the life of me undstand how it does it :/ any idea how this is possible ?

  2. #2
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654

    Re: how does this work

    Files can be read from the disk at any time. Writing into active files might be locked/prevented, but reading is often possible (as reading is rarely locked).

  3. #3
    Frenzied Member Andrew G's Avatar
    Join Date
    Nov 2005
    Location
    Sydney
    Posts
    1,587

    Re: how does this work

    Its better to use App.ExeName as title can be changed at runtime. Also i can't understand why it doesn't seem possible... could you explain?

  4. #4

    Thread Starter
    Fanatic Member dark_shadow's Avatar
    Join Date
    Feb 2005
    Location
    Igloo
    Posts
    900

    Re: how does this work

    i thought it wouldnt be possible to copy it because its in use

  5. #5
    Frenzied Member Andrew G's Avatar
    Join Date
    Nov 2005
    Location
    Sydney
    Posts
    1,587

    Re: how does this work

    Nah as Merri said, although it is in use, it can still be read. Its the same as opening 2 instances of the same exe. If it was in use, then the second instance would not be able to open.

  6. #6
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654

    Re: how does this work

    Executables are (mostly) read (= copied) to memory.

  7. #7

    Thread Starter
    Fanatic Member dark_shadow's Avatar
    Join Date
    Feb 2005
    Location
    Igloo
    Posts
    900

    Re: how does this work

    so that explains why if i change the app.title to app.exename as Andrew suggested and try to run the copy i get a permission denied error?

  8. #8
    Frenzied Member Andrew G's Avatar
    Join Date
    Nov 2005
    Location
    Sydney
    Posts
    1,587

    Re: how does this work

    Quote Originally Posted by dark_shadow
    so that explains why if i change the app.title to app.exename as Andrew suggested and try to run the copy i get a permission denied error?
    If you run the copy (which will be named "myapp.exe" ) it will try to copy this exe to the C drive and name it "myapp.exe", which is the same file so hence you can't copy the exe and overwrite it with itself....

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