Visual Basic - Question

Discussion in 'Web Design & Coding' started by lieb39, Jan 31, 2003.

  1. lieb39

    lieb39 Apple lover, PC User

    Is it possible in Visual Basic to rename, overright or delete a file on the hard drive? How? (Step by step is the best...)

  2. XPletive

    XPletive bbbb-ring...

    Sure there is.

    Use the Name statement to rename a file.

    Use Kill to delete a file.

    VB will overwrite files automatically. That's why
    it's good practice to check for the existance of the
    file and ask the user if the want to overwrite it.

    Seach VB Help for Name and Kill
  3. EventHorizon

    EventHorizon Guest

    Oh no no no no no.

    There is a much better, and safer way to rename/delete/copy/move files in VB.

    Depends on your VB version, assuming VB6 you want to look at the File System Object (check it out on or

    name and kill do work, but you have very little control over what they do. The FSO also give you a better error message when a file is in use etc...

    Have fun!
  4. a1ehouse

    a1ehouse Chamone M*tha Fu*ka

    Open notepad, copy this as test.vbs and save. Double click it to run!

  5. XPletive

    XPletive bbbb-ring...

    File System Object assumes a couple of things.

    1. A more recent version of VB
    2. A slightly more experienced VB programmer.

    I find it better to start people off with the basics.

    I will agree that is offers better error handling, but
    most new programmers don't have an understanding
    of the importance of that anyway.