Results 1 to 10 of 10
  1. #1
    3 Star Lounger
    Join Date
    May 2002
    Location
    Florence, Oregon, USA
    Posts
    209
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Rename a File (VB 2008 Express Edition)

    I use the methods of the File class to perform utility functions on existing files. I notice, however, that there is no Rename method. How does one do a simple file rename in VB?

    Thank you

    John Littell

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Rename a File (VB 2008 Express Edition)

    Please post your questions in the appropriate forum. This is a .Net question, not classic VB, just like <post:=721,406>post 721,406</post:> some weeks ago.
    I'll move the thread <img src=/S/sigh.gif border=0 alt=sigh width=15 height=15>

  3. #3
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Re: Rename a File (VB 2008 Express Edition)

    I think you just use MoveTo with the new name.
    Regards,
    Rory

    Microsoft MVP - Excel

  4. #4
    Star Lounger
    Join Date
    Sep 2004
    Location
    Wolverhampton, Staffordshire, England
    Posts
    86
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Rename a File (VB 2008 Express Edition)

    I refer you to the msdn article and the snippet

    My.Computer.FileSystem.RenameFile("C:Test.txt", "SecondTest.txt")

  5. #5
    3 Star Lounger
    Join Date
    May 2002
    Location
    Florence, Oregon, USA
    Posts
    209
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Rename a File (VB 2008 Express Edition)

    My thanks go to all responders. It is so simple when you know.

    John

    PS. What determines this a .net question, not a VB question?

  6. #6
    Star Lounger
    Join Date
    Sep 2004
    Location
    Wolverhampton, Staffordshire, England
    Posts
    86
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Rename a File (VB 2008 Express Edition)

    After version 7 they unified their products into a group known as .NET, using core libraries from the .NET framework. (Version 8 being 2005, version 9 being 2008)

  7. #7
    3 Star Lounger
    Join Date
    May 2002
    Location
    Florence, Oregon, USA
    Posts
    209
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Rename a File (VB 2008 Express Edition)

    Danny D.
    Sorry for the delayed response. The Lounge seemed to be down yesterday.

    Does your answer mean that the VB/VBA category now applies only to version 6 and earlier?

    John

  8. #8
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Rename a File (VB 2008 Express Edition)

    The Lounge hasn't been down, but it's very slow every day between 23:00 and 01:00 UTC because the daily backup is made durong that time - see for example the thread starting at <post:=719,531>post 719,531</post:>.

  9. #9
    Star Lounger
    Join Date
    Sep 2004
    Location
    Wolverhampton, Staffordshire, England
    Posts
    86
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Rename a File (VB 2008 Express Edition)

    Yes, as the .NET section refers to the .NET package, i anticipate the VB/VBA section to mean only pre-.NET articles

  10. #10
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Rename a File (VB 2008 Express Edition)

    Sorry, I don't monitor the .Net forum closely, so I missed your PS.

    Danny is correct. VB5 / VB6 and (Office) VBA all use "classic" Visual Basic. Questions about those can be posted in the VB / VBA forum.
    VB.NET, VB2003, VB2005 and VB2008 all use a newer version of Visual Basic that is quite different from "classic" VB, so there's a separate forum for everything related to these versions.

    See Visual Basic .NET on Wikipedia for an overview.

Posting Permissions

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